From 322f6f0518f2fca892733dea85d87c33fcb65e83 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Sat, 5 Apr 2008 18:41:37 +0000 Subject: [PATCH] Bug #20028 (Debian bug 399271): fix code assuming that pointer differences were 32 bits -- thanks to Dean Gaudet for the patch. --- ChangeLog | 5 +++++ sbr/fmt_scan.c | 2 +- sbr/lock_file.c | 4 ++-- sbr/m_backup.c | 2 +- sbr/m_getfld.c | 4 ++-- sbr/m_scratch.c | 2 +- sbr/mf.c | 2 +- sbr/path.c | 4 ++-- uip/annosbr.c | 2 +- uip/dropsbr.c | 6 +++--- uip/mhbuildsbr.c | 2 +- uip/mhparse.c | 2 +- uip/slocal.c | 4 ++-- 13 files changed, 23 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index ffa4e93..4023e45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-04-05 Peter Maydell + + * bug #20028 (Debian bug 399271): fix code assuming that pointer + differences were 32 bits -- thanks to Dean Gaudet for the patch. + 2008-01-25 Josh Bressers * uip/mhshowsbr.c (show_all_messages): Be more generous when parsing diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index c3d265a..ca4020b 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -288,7 +288,7 @@ get_x400_comp (char *mbox, char *key, char *buffer, int buffer_len) || !(cp = strchr(mbox += idx + strlen (key), '/'))) return 0; - snprintf (buffer, buffer_len, "%*.*s", cp - mbox, cp - mbox, mbox); + snprintf (buffer, buffer_len, "%*.*s", (int)(cp - mbox), (int)(cp - mbox), mbox); return 1; } diff --git a/sbr/lock_file.c b/sbr/lock_file.c index 65b8907..866d047 100644 --- a/sbr/lock_file.c +++ b/sbr/lock_file.c @@ -494,7 +494,7 @@ lockname (char *file, struct lockinfo *li, int isnewlock) bplen += tmplen; #else if (cp != file) { - snprintf (bp, sizeof(li->curlock), "%.*s", cp - file, file); + snprintf (bp, sizeof(li->curlock), "%.*s", (int)(cp - file), file); tmplen = strlen (bp); bp += tmplen; bplen += tmplen; @@ -526,7 +526,7 @@ lockname (char *file, struct lockinfo *li, int isnewlock) strncpy (li->tmplock, ",LCK.XXXXXX", sizeof(li->tmplock)); else snprintf (li->tmplock, sizeof(li->tmplock), "%.*s,LCK.XXXXXX", - cp - li->curlock, li->curlock); + (int)(cp - li->curlock), li->curlock); } #endif } diff --git a/sbr/m_backup.c b/sbr/m_backup.c index 86696db..9dcfdf6 100644 --- a/sbr/m_backup.c +++ b/sbr/m_backup.c @@ -22,7 +22,7 @@ m_backup (char *file) snprintf(buffer, sizeof(buffer), "%s%s", BACKUP_PREFIX, cp); else - snprintf(buffer, sizeof(buffer), "%.*s%s%s", cp - file, file, + snprintf(buffer, sizeof(buffer), "%.*s%s%s", (int)(cp - file), file, BACKUP_PREFIX, cp); unlink(buffer); diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index 6c15886..59b8682 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -700,10 +700,10 @@ get_returnpath (char *rp, int rplen, char *dd, int ddlen) if (cp) { /* return path for UUCP style addressing */ dp = strchr (++cp, '\n'); - snprintf (rp, rplen, "%.*s!%.*s\n", dp - cp, cp, bp - ap, ap); + snprintf (rp, rplen, "%.*s!%.*s\n", (int)(dp - cp), cp, (int)(bp - ap), ap); } else { /* return path for standard domain addressing */ - snprintf (rp, rplen, "%.*s\n", bp - ap, ap); + snprintf (rp, rplen, "%.*s\n", (int)(bp - ap), ap); } /* diff --git a/sbr/m_scratch.c b/sbr/m_scratch.c index 30601f1..df63531 100644 --- a/sbr/m_scratch.c +++ b/sbr/m_scratch.c @@ -33,7 +33,7 @@ m_scratch (char *file, char *template) if ((cp = r1bindex (file, '/')) == file) strncpy (buffer, tmpfil, sizeof(buffer)); else - snprintf (buffer, sizeof(buffer), "%.*s%s", cp - file, file, tmpfil); + snprintf (buffer, sizeof(buffer), "%.*s%s", (int)(cp - file), file, tmpfil); unlink (buffer); return buffer; diff --git a/sbr/mf.c b/sbr/mf.c index 2559b67..ac04c29 100644 --- a/sbr/mf.c +++ b/sbr/mf.c @@ -421,7 +421,7 @@ getadrx (char *addrs) while (isspace (*ap)) ap++; if (cp) - sprintf (adr, "%.*s", cp - ap, ap); + sprintf (adr, "%.*s", (int)(cp - ap), ap); else strcpy (adr, ap); bp = adr + strlen (adr) - 1; diff --git a/sbr/path.c b/sbr/path.c index 7475fa0..7ef83ea 100644 --- a/sbr/path.c +++ b/sbr/path.c @@ -90,7 +90,7 @@ expath (char *name, int flag) name += NCWD; if (strcmp (name, DOTDOT) == 0 || strcmp (name, PWD) == 0) { - snprintf (buffer, sizeof(buffer), "%.*s", cp - pwds, pwds); + snprintf (buffer, sizeof(buffer), "%.*s", (int)(cp - pwds), pwds); return getcpy (buffer); } @@ -99,7 +99,7 @@ expath (char *name, int flag) else cp = ep; - snprintf (buffer, sizeof(buffer), "%.*s/%s", cp - pwds, pwds, name); + snprintf (buffer, sizeof(buffer), "%.*s/%s", (int)(cp - pwds), pwds, name); return getcpy (buffer); } diff --git a/uip/annosbr.c b/uip/annosbr.c index 2ad873e..e8ef50a 100644 --- a/uip/annosbr.c +++ b/uip/annosbr.c @@ -381,7 +381,7 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace, int datesw, in while (*cp && *cp++ != '\n') continue; if (cp - sp) - fprintf (tmp, "%s: %*.*s", comp, cp - sp, cp - sp, sp); + fprintf (tmp, "%s: %*.*s", comp, (int)(cp - sp), (int)(cp - sp), sp); } while (*cp); if (cp[-1] != '\n' && cp != text) putc ('\n', tmp); diff --git a/uip/dropsbr.c b/uip/dropsbr.c index 2b3d020..84435a2 100644 --- a/uip/dropsbr.c +++ b/uip/dropsbr.c @@ -376,7 +376,7 @@ mbx_copy (char *mailbox, int mbx_style, int md, int fd, fp = strchr(ep + 1, '\n'); tp = dctime(dlocaltimenow()); snprintf (buffer, sizeof(buffer), "From %.*s %s", - fp - ep, ep, tp); + (int)(fp - ep), ep, tp); } else if (!strncmp (buffer, "X-Envelope-From:", 16)) { /* * Change the "X-Envelope-From:" field @@ -488,10 +488,10 @@ map_name (char *file) if ((dp = strchr(cp = r1bindex (file, '/'), '.')) == NULL) dp = cp + strlen (cp); if (cp == file) - snprintf (buffer, sizeof(buffer), ".%.*s%s", dp - cp, cp, ".map"); + snprintf (buffer, sizeof(buffer), ".%.*s%s", (int)(dp - cp), cp, ".map"); else snprintf (buffer, sizeof(buffer), "%.*s.%.*s%s", - cp - file, file, dp - cp, cp, ".map"); + (int)(cp - file), file, (int)(dp - cp), cp, ".map"); return buffer; } diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index 041a142..76866fe 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -4309,7 +4309,7 @@ invalid_digest: while (*cp) cp++; fprintf (stderr, "invalid MD5 digest (got %d octets)\n", - cp - bp); + (int)(cp - bp)); } return NOTOK; diff --git a/uip/mhparse.c b/uip/mhparse.c index a348144..4887d9a 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -2684,7 +2684,7 @@ invalid_digest: while (*cp) cp++; fprintf (stderr, "invalid MD5 digest (got %d octets)\n", - cp - bp); + (int)(cp - bp)); } return NOTOK; diff --git a/uip/slocal.c b/uip/slocal.c index 1396cc2..f500f6e 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -1361,11 +1361,11 @@ you_lose: /* return path for UUCP style addressing */ ep = strchr(++hp, '\n'); snprintf (buffer, sizeof(buffer), "Return-Path: %.*s!%.*s\n", - ep - hp, hp, cp - fp, fp); + (int)(ep - hp), hp, (int)(cp - fp), fp); } else { /* return path for standard domain addressing */ snprintf (buffer, sizeof(buffer), "Return-Path: %.*s\n", - cp - fp, fp); + (int)(cp - fp), fp); } /* Add Return-Path header to message */ -- 1.7.10.4