summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Yanovich <jaredy@cvs.openbsd.org>2004-10-05 14:46:12 +0000
committerJared Yanovich <jaredy@cvs.openbsd.org>2004-10-05 14:46:12 +0000
commit836c209470564add0501dcbe65e1fb2f51d3d653 (patch)
tree9529bc582548d938575a680a85244ca250c26f09
parent65f9f78468ffdbfeceffca7e3904d4e22f25ba37 (diff)
fix an overflow in the handling of -S
ok millert
-rw-r--r--usr.bin/tput/tput.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/usr.bin/tput/tput.c b/usr.bin/tput/tput.c
index 433b1bdad8f..d90d9df7f9e 100644
--- a/usr.bin/tput/tput.c
+++ b/usr.bin/tput/tput.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tput.c,v 1.15 2003/06/17 21:56:26 millert Exp $ */
+/* $OpenBSD: tput.c,v 1.16 2004/10/05 14:46:11 jaredy Exp $ */
/*
* Copyright (c) 1999 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -54,7 +54,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)tput.c 8.3 (Berkeley) 4/28/95";
#endif
-static char rcsid[] = "$OpenBSD: tput.c,v 1.15 2003/06/17 21:56:26 millert Exp $";
+static char rcsid[] = "$OpenBSD: tput.c,v 1.16 2004/10/05 14:46:11 jaredy Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -135,14 +135,14 @@ main(int argc, char *argv[])
if (str[len-1] != '\n')
errx(1, "premature EOF");
str[len-1] = '\0';
- /* grow av as needed */
- if (argc + 1 >= n) {
- n += 64;
- av = (char **)realloc(av, sizeof(char *) * n);
- if (av == NULL)
- errx(1, "out of memory");
- }
while ((p = strsep(&str, " \t")) != NULL) {
+ /* grow av as needed */
+ if (argc + 1 >= n) {
+ n += 64;
+ av = (char **)realloc(av, sizeof(char *) * n);
+ if (av == NULL)
+ errx(1, "out of memory");
+ }
if (*p != '\0' &&
(av[argc++] = strdup(p)) == NULL)
errx(1, "out of memory");