diff options
-rw-r--r-- | usr.bin/column/column.c | 14 | ||||
-rw-r--r-- | usr.bin/find/main.c | 9 | ||||
-rw-r--r-- | usr.bin/find/misc.c | 14 | ||||
-rw-r--r-- | usr.bin/fold/fold.c | 12 | ||||
-rw-r--r-- | usr.bin/indent/io.c | 11 | ||||
-rw-r--r-- | usr.bin/indent/lexi.c | 14 |
6 files changed, 46 insertions, 28 deletions
diff --git a/usr.bin/column/column.c b/usr.bin/column/column.c index af90ee2b37c..f97a289eec0 100644 --- a/usr.bin/column/column.c +++ b/usr.bin/column/column.c @@ -1,4 +1,4 @@ -/* $OpenBSD: column.c,v 1.9 2003/06/10 22:20:45 deraadt Exp $ */ +/* $OpenBSD: column.c,v 1.10 2003/09/26 22:24:09 tedu Exp $ */ /* $NetBSD: column.c,v 1.4 1995/09/02 05:53:03 jtc Exp $ */ /* @@ -40,7 +40,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)column.c 8.4 (Berkeley) 5/4/95"; #endif -static char rcsid[] = "$OpenBSD: column.c,v 1.9 2003/06/10 22:20:45 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: column.c,v 1.10 2003/09/26 22:24:09 tedu Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -212,9 +212,9 @@ maketbl(void) TBL *t; int coloff, cnt; char *p, **lp; - int *lens, maxcols; + int *lens, *lens2, maxcols; TBL *tbl; - char **cols; + char **cols, **cols2; t = tbl = emalloc(entries * sizeof(TBL)); cols = emalloc((maxcols = DEFCOLS) * sizeof(char *)); @@ -223,11 +223,13 @@ maketbl(void) for (coloff = 0, p = *lp; (cols[coloff] = strtok(p, separator)); p = NULL) if (++coloff == maxcols) { - if (!(cols = realloc(cols, (u_int)maxcols + + if (!(cols2 = realloc(cols, (u_int)maxcols + DEFCOLS * sizeof(char *))) || - !(lens = realloc(lens, + !(lens2 = realloc(lens, (u_int)maxcols + DEFCOLS * sizeof(int)))) err(1, NULL); + cols = cols2; + lens = lens2; memset((char *)lens + maxcols * sizeof(int), 0, DEFCOLS * sizeof(int)); maxcols += DEFCOLS; diff --git a/usr.bin/find/main.c b/usr.bin/find/main.c index df8de968628..68a93604372 100644 --- a/usr.bin/find/main.c +++ b/usr.bin/find/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.16 2003/06/10 22:20:46 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.17 2003/09/26 22:22:26 tedu Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -31,7 +31,7 @@ #ifndef lint /*static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$OpenBSD: main.c,v 1.16 2003/06/10 22:20:46 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.17 2003/09/26 22:22:26 tedu Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -63,7 +63,7 @@ int main(int argc, char *argv[]) { struct sigaction sa; - char **p, **paths; + char **p, **paths, **paths2; int ch; memset(&sa, 0, sizeof sa); @@ -126,8 +126,9 @@ main(int argc, char *argv[]) usage(); *p = NULL; - if (!(paths = realloc(paths, sizeof(char *) * (p - paths + 1)))) + if (!(paths2 = realloc(paths, sizeof(char *) * (p - paths + 1)))) err(1, NULL); + paths = paths2; if ((dotfd = open(".", O_RDONLY, 0)) < 0) err(1, ".:"); diff --git a/usr.bin/find/misc.c b/usr.bin/find/misc.c index ad343b56e18..0635129f850 100644 --- a/usr.bin/find/misc.c +++ b/usr.bin/find/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.9 2003/06/26 07:27:29 deraadt Exp $ */ +/* $OpenBSD: misc.c,v 1.10 2003/09/26 22:22:26 tedu Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -34,7 +34,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)misc.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$OpenBSD: misc.c,v 1.9 2003/06/26 07:27:29 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: misc.c,v 1.10 2003/09/26 22:22:26 tedu Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -64,9 +64,15 @@ brace_subst(char *orig, char **store, char *path, int len) plen = strlen(path); for (p = *store; (ch = *orig); ++orig) if (ch == '{' && orig[1] == '}') { - while ((p - *store) + plen > len) - if (!(*store = realloc(*store, len *= 2))) + while ((p - *store) + plen > len) { + int newlen = len * 2; + char *newstore; + + if (!(newstore = realloc(*store, newlen))) err(1, NULL); + *store = newstore; + len = newlen; + } memmove(p, path, plen); p += plen; ++orig; diff --git a/usr.bin/fold/fold.c b/usr.bin/fold/fold.c index 6619f577642..42588420456 100644 --- a/usr.bin/fold/fold.c +++ b/usr.bin/fold/fold.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fold.c,v 1.9 2003/06/25 21:19:19 deraadt Exp $ */ +/* $OpenBSD: fold.c,v 1.10 2003/09/26 22:22:50 tedu Exp $ */ /* $NetBSD: fold.c,v 1.6 1995/09/01 01:42:44 jtc Exp $ */ /*- @@ -43,7 +43,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)fold.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: fold.c,v 1.9 2003/06/25 21:19:19 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: fold.c,v 1.10 2003/09/26 22:22:50 tedu Exp $"; #endif /* not lint */ #include <stdio.h> @@ -172,12 +172,16 @@ fold(int width) } if (indx + 1 > buf_max) { + int newmax = buf_max + 2048; + char *newbuf; + /* Allocate buffer in LINE_MAX increments */ - buf_max += 2048; - if((buf = realloc(buf, buf_max)) == NULL) { + if ((newbuf = realloc(buf, newmax)) == NULL) { err(1, NULL); /* NOTREACHED */ } + buf = newbuf; + buf_max = newmax; } buf[indx++] = ch; } diff --git a/usr.bin/indent/io.c b/usr.bin/indent/io.c index a555768ace5..73ed875ea58 100644 --- a/usr.bin/indent/io.c +++ b/usr.bin/indent/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.7 2003/06/03 02:56:09 millert Exp $ */ +/* $OpenBSD: io.c,v 1.8 2003/09/26 22:23:28 tedu Exp $ */ /* * Copyright (c) 1985 Sun Microsystems, Inc. @@ -33,7 +33,7 @@ #ifndef lint /*static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$OpenBSD: io.c,v 1.7 2003/06/03 02:56:09 millert Exp $"; +static char rcsid[] = "$OpenBSD: io.c,v 1.8 2003/09/26 22:23:28 tedu Exp $"; #endif /* not lint */ #include <stdio.h> @@ -337,7 +337,7 @@ compute_label_target() void fill_buffer() { /* this routine reads stuff from the input */ - char *p; + char *p, *buf2; int i; FILE *f = input; @@ -353,9 +353,10 @@ fill_buffer() if (p >= in_buffer_limit) { int size = (in_buffer_limit - in_buffer) * 2 + 10; int offset = p - in_buffer; - in_buffer = (char *) realloc(in_buffer, size); - if (in_buffer == NULL) + buf2 = realloc(in_buffer, size); + if (buf2 == NULL) errx(1, "input line too long"); + in_buffer = buf2; p = in_buffer + offset; in_buffer_limit = in_buffer + size - 2; } diff --git a/usr.bin/indent/lexi.c b/usr.bin/indent/lexi.c index 774ca6b7d9a..fa62b4740a6 100644 --- a/usr.bin/indent/lexi.c +++ b/usr.bin/indent/lexi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lexi.c,v 1.9 2003/06/12 01:07:27 deraadt Exp $ */ +/* $OpenBSD: lexi.c,v 1.10 2003/09/26 22:23:28 tedu Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #ifndef lint /*static char sccsid[] = "@(#)lexi.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$OpenBSD: lexi.c,v 1.9 2003/06/12 01:07:27 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: lexi.c,v 1.10 2003/09/26 22:23:28 tedu Exp $"; #endif /* not lint */ /* @@ -589,10 +589,14 @@ addkey(key, val) err(1, NULL); memmove(specials, specialsinit, sizeof specialsinit); } else if (nspecials >= maxspecials) { - maxspecials += maxspecials >> 2; - specials = realloc(specials, maxspecials * sizeof specials[0]); - if (specials == NULL) + int newspecials = maxspecials + maxspecials >> 2; + struct templ *specials2; + + specials2 = realloc(specials, newspecials * sizeof specials[0]); + if (specials2 == NULL) err(1, NULL); + specials = specials2; + maxspecials = newspecials; } p = &specials[i]; |