diff options
-rw-r--r-- | usr.bin/mail/aux.c | 27 | ||||
-rw-r--r-- | usr.bin/mail/cmd2.c | 6 | ||||
-rw-r--r-- | usr.bin/mail/cmd3.c | 7 | ||||
-rw-r--r-- | usr.bin/mail/collect.c | 7 | ||||
-rw-r--r-- | usr.bin/mail/extern.h | 6 | ||||
-rw-r--r-- | usr.bin/mail/lex.c | 10 |
6 files changed, 36 insertions, 27 deletions
diff --git a/usr.bin/mail/aux.c b/usr.bin/mail/aux.c index a0a9010a76e..9151a3ba900 100644 --- a/usr.bin/mail/aux.c +++ b/usr.bin/mail/aux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aux.c,v 1.9 1997/07/28 15:20:28 millert Exp $ */ +/* $OpenBSD: aux.c,v 1.10 1997/07/30 07:19:29 millert Exp $ */ /* $NetBSD: aux.c,v 1.5 1997/05/13 06:15:52 mikel Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)aux.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: aux.c,v 1.9 1997/07/28 15:20:28 millert Exp $"; +static char rcsid[] = "$OpenBSD: aux.c,v 1.10 1997/07/30 07:19:29 millert Exp $"; #endif #endif /* not lint */ @@ -277,19 +277,24 @@ ishfield(linebuf, colon, field) } /* - * Copy a string, lowercasing it as we go. + * Copy a string, lowercasing it as we go. ``dsize'' should be + * the real size (not len) of the dest string (guarantee NULL term). */ void -istrcpy(dest, src) +istrncpy(dest, src, dsize) register char *dest, *src; + register size_t dsize; { - do { - if (isupper(*src)) - *dest++ = tolower(*src); - else - *dest++ = *src; - } while (*src++ != 0); + if (dsize != 0) { + while (--dsize != 0 && *src != '\0') { + if (isupper(*src)) + *dest++ = tolower(*src++); + else + *dest++ = *src++; + } + *dest = '\0'; + } } /* @@ -695,7 +700,7 @@ isign(field, ignore) * Lower-case the string, so that "Status" and "status" * will hash to the same place. */ - istrcpy(realfld, field); + istrncpy(realfld, field, sizeof(realfld)); if (ignore[1].i_count > 0) return(!member(realfld, ignore + 1)); else diff --git a/usr.bin/mail/cmd2.c b/usr.bin/mail/cmd2.c index f263d220451..e42db4c3dab 100644 --- a/usr.bin/mail/cmd2.c +++ b/usr.bin/mail/cmd2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd2.c,v 1.5 1997/07/14 00:24:24 millert Exp $ */ +/* $OpenBSD: cmd2.c,v 1.6 1997/07/30 07:19:29 millert Exp $ */ /* $NetBSD: cmd2.c,v 1.7 1997/05/17 19:55:10 pk Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)cmd2.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: cmd2.c,v 1.5 1997/07/14 00:24:24 millert Exp $"; +static char rcsid[] = "$OpenBSD: cmd2.c,v 1.6 1997/07/30 07:19:29 millert Exp $"; #endif #endif /* not lint */ @@ -496,7 +496,7 @@ ignore1(list, tab, which) if (*list == NULL) return(igshow(tab, which)); for (ap = list; *ap != 0; ap++) { - istrcpy(field, *ap); + istrncpy(field, *ap, sizeof(field)); if (member(field, tab)) continue; h = hash(field); diff --git a/usr.bin/mail/cmd3.c b/usr.bin/mail/cmd3.c index accc7f4f56d..a991e37c384 100644 --- a/usr.bin/mail/cmd3.c +++ b/usr.bin/mail/cmd3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd3.c,v 1.8 1997/07/30 06:32:38 millert Exp $ */ +/* $OpenBSD: cmd3.c,v 1.9 1997/07/30 07:19:30 millert Exp $ */ /* $NetBSD: cmd3.c,v 1.8 1997/07/09 05:29:49 mikel Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)cmd3.c 8.2 (Berkeley) 4/20/95"; #else -static char rcsid[] = "$OpenBSD: cmd3.c,v 1.8 1997/07/30 06:32:38 millert Exp $"; +static char rcsid[] = "$OpenBSD: cmd3.c,v 1.9 1997/07/30 07:19:30 millert Exp $"; #endif #endif /* not lint */ @@ -122,7 +122,8 @@ overf: return(-1); } changed++; - strcpy(cp2, lastbang); + strncpy(cp2, lastbang, sizeof(bangbuf) - (cp2 - bangbuf) - 1); + bangbuf[sizeof(bangbuf) - 1] = '\0'; cp2 += strlen(lastbang); n -= strlen(lastbang); cp++; diff --git a/usr.bin/mail/collect.c b/usr.bin/mail/collect.c index 6dcee7fdef1..7a94f0c1ded 100644 --- a/usr.bin/mail/collect.c +++ b/usr.bin/mail/collect.c @@ -1,4 +1,4 @@ -/* $OpenBSD: collect.c,v 1.13 1997/07/30 06:32:39 millert Exp $ */ +/* $OpenBSD: collect.c,v 1.14 1997/07/30 07:19:30 millert Exp $ */ /* $NetBSD: collect.c,v 1.9 1997/07/09 05:25:45 mikel Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)collect.c 8.2 (Berkeley) 4/19/94"; #else -static char rcsid[] = "$OpenBSD: collect.c,v 1.13 1997/07/30 06:32:39 millert Exp $"; +static char rcsid[] = "$OpenBSD: collect.c,v 1.14 1997/07/30 07:19:30 millert Exp $"; #endif #endif /* not lint */ @@ -282,7 +282,8 @@ cont: hp->h_bcc = cat(hp->h_bcc, extract(&linebuf[2], GBCC)); break; case 'd': - strcpy(linebuf + 2, getdeadletter()); + strncpy(linebuf + 2, getdeadletter(), sizeof(linebuf) - 3); + linebuf[sizeof(linebuf) - 1] = '\0'; /* fall into . . . */ case 'r': case '<': diff --git a/usr.bin/mail/extern.h b/usr.bin/mail/extern.h index a1e5870fbd1..5b9c1aa13f6 100644 --- a/usr.bin/mail/extern.h +++ b/usr.bin/mail/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.10 1997/07/30 06:32:39 millert Exp $ */ +/* $OpenBSD: extern.h,v 1.11 1997/07/30 07:19:30 millert Exp $ */ /* $NetBSD: extern.h,v 1.7 1997/07/09 05:22:00 mikel Exp $ */ /*- @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)extern.h 8.2 (Berkeley) 4/20/95 - * $OpenBSD: extern.h,v 1.10 1997/07/30 06:32:39 millert Exp $ + * $OpenBSD: extern.h,v 1.11 1997/07/30 07:19:30 millert Exp $ */ struct name; @@ -167,7 +167,7 @@ int isfileaddr __P((char *)); int ishead __P((char [])); int isign __P((char *, struct ignoretab [])); int isprefix __P((char *, char *)); -void istrcpy __P((char *, char *)); +void istrncpy __P((char *, char *, size_t)); const struct cmd * lex __P((char [])); void load __P((char *)); diff --git a/usr.bin/mail/lex.c b/usr.bin/mail/lex.c index 1e59ce5e25b..2bd671ede6f 100644 --- a/usr.bin/mail/lex.c +++ b/usr.bin/mail/lex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.c,v 1.13 1997/07/30 06:32:40 millert Exp $ */ +/* $OpenBSD: lex.c,v 1.14 1997/07/30 07:19:31 millert Exp $ */ /* $NetBSD: lex.c,v 1.10 1997/05/17 19:55:13 pk Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)lex.c 8.2 (Berkeley) 4/20/95"; #else -static char rcsid[] = "$OpenBSD: lex.c,v 1.13 1997/07/30 06:32:40 millert Exp $"; +static char rcsid[] = "$OpenBSD: lex.c,v 1.14 1997/07/30 07:19:31 millert Exp $"; #endif #endif /* not lint */ @@ -134,8 +134,10 @@ setfile(name) shudclob = 1; edit = isedit; strcpy(prevfile, mailname); - if (name != mailname) - strcpy(mailname, name); + if (name != mailname) { + strncpy(mailname, name, sizeof(mailname) - 1); + mailname[sizeof(mailname) - 1] = '\0'; + } mailsize = fsize(ibuf); (void)snprintf(tempname, sizeof(tempname), "%s/mail.RxXXXXXXXXXX", tmpdir); |