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/list.c | |
parent | 1670d064f3fd33d5b362292ecab50643d9f0adfb (diff) |
Document an assumption and kill a static buffer.
Diffstat (limited to 'usr.bin/mail/list.c')
-rw-r--r-- | usr.bin/mail/list.c | 18 |
1 files changed, 15 insertions, 3 deletions
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); } |