diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1997-07-31 02:36:34 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1997-07-31 02:36:34 +0000 |
commit | 4addf81b99a51150945ce75f6f8254af708cdff1 (patch) | |
tree | 0b85fa84c145387a6bfd8fb28cdc59c3b09bd575 /usr.bin/mail | |
parent | 1670d064f3fd33d5b362292ecab50643d9f0adfb (diff) |
Document an assumption and kill a static buffer.
Diffstat (limited to 'usr.bin/mail')
-rw-r--r-- | usr.bin/mail/aux.c | 6 | ||||
-rw-r--r-- | usr.bin/mail/list.c | 18 |
2 files changed, 19 insertions, 5 deletions
diff --git a/usr.bin/mail/aux.c b/usr.bin/mail/aux.c index 9151a3ba900..c3f6a885938 100644 --- a/usr.bin/mail/aux.c +++ b/usr.bin/mail/aux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aux.c,v 1.10 1997/07/30 07:19:29 millert Exp $ */ +/* $OpenBSD: aux.c,v 1.11 1997/07/31 02:36:32 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.10 1997/07/30 07:19:29 millert Exp $"; +static char rcsid[] = "$OpenBSD: aux.c,v 1.11 1997/07/31 02:36:32 millert Exp $"; #endif #endif /* not lint */ @@ -473,6 +473,8 @@ skin(name) if (strchr(name, '(') == NULL && strchr(name, '<') == NULL && strchr(name, ' ') == NULL) return(name); + + /* We assume that length(input) <= length(output) */ if ((bufend = (char *)malloc(strlen(name) + 1)) == NULL) panic("Out of memory"); gotlt = 0; diff --git a/usr.bin/mail/list.c b/usr.bin/mail/list.c index b653dadf7a3..691d1140029 100644 --- a/usr.bin/mail/list.c +++ b/usr.bin/mail/list.c @@ -1,4 +1,4 @@ -/* $OpenBSD: list.c,v 1.6 1997/07/14 00:24:28 millert Exp $ */ +/* $OpenBSD: list.c,v 1.7 1997/07/31 02:36:33 millert Exp $ */ /* $NetBSD: list.c,v 1.7 1997/07/09 05:23:36 mikel Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)list.c 8.4 (Berkeley) 5/1/95"; #else -static char rcsid[] = "$OpenBSD: list.c,v 1.6 1997/07/14 00:24:28 millert Exp $"; +static char rcsid[] = "$OpenBSD: list.c,v 1.7 1997/07/31 02:36:33 millert Exp $"; #endif #endif /* not lint */ @@ -398,7 +398,11 @@ getrawlist(line, argv, argc) { register char c, *cp, *cp2, quotec; int argn; - char linebuf[BUFSIZ]; + char *linebuf; + size_t linebufsize = BUFSIZ; + + if ((linebuf = (char *)malloc(linebufsize)) == NULL) + panic("Out of memory"); argn = 0; cp = line; @@ -414,6 +418,13 @@ getrawlist(line, argv, argc) cp2 = linebuf; quotec = '\0'; while ((c = *cp) != '\0') { + /* Alloc more space if necessary */ + if (cp2 - linebuf == linebufsize - 1) { + linebufsize += BUFSIZ; + if (!(linebuf = realloc(linebuf, linebufsize))) + panic("Out of memory"); + cp2 = linebuf + (linebufsize - BUFSIZ) - 1; + } cp++; if (quotec != '\0') { if (c == quotec) @@ -479,6 +490,7 @@ getrawlist(line, argv, argc) argv[argn++] = savestr(linebuf); } argv[argn] = NULL; + (void)free(linebuf); return(argn); } |