summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2000-12-22 22:53:11 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2000-12-22 22:53:11 +0000
commita1b92401eb39772968a923b3bcde7607a35cdbcd (patch)
tree75d21065fe28568790ce9a131f6b2eb2461727e7 /bin
parent2b4ad7a6eda15544ea3b5b87c7258ceda7a7053d (diff)
repair same static buf oflow in printf(1) and printf(1) internal inside csh(1)
Diffstat (limited to 'bin')
-rw-r--r--bin/csh/printf.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/bin/csh/printf.c b/bin/csh/printf.c
index 5c46dd5b591..d680ff19287 100644
--- a/bin/csh/printf.c
+++ b/bin/csh/printf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printf.c,v 1.9 2000/01/22 20:24:47 deraadt Exp $ */
+/* $OpenBSD: printf.c,v 1.10 2000/12/22 22:53:10 deraadt Exp $ */
/* $NetBSD: printf.c,v 1.6 1995/03/21 09:03:15 cgd Exp $ */
/*
@@ -46,7 +46,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)printf.c 8.1 (Berkeley) 7/20/93";
#else
-static char rcsid[] = "$OpenBSD: printf.c,v 1.9 2000/01/22 20:24:47 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: printf.c,v 1.10 2000/12/22 22:53:10 deraadt Exp $";
#endif
#endif /* not lint */
@@ -227,10 +227,24 @@ mklong(str, ch)
char *str;
int ch;
{
- static char copy[64];
+ static char *copy;
+ static int copysize;
int len;
len = strlen(str) + 2;
+ if (copysize < len) {
+ char *newcopy;
+ copysize = len + 256;
+
+ newcopy = realloc(copy, copysize);
+ if (newcopy == NULL) {
+ copysize = 0;
+ free(copy);
+ copy = NULL;
+ return (NULL);
+ }
+ copy = newcopy;
+ }
memmove(copy, str, len - 3);
copy[len - 3] = 'l';
copy[len - 2] = ch;