summaryrefslogtreecommitdiff
path: root/usr.bin/printf/printf.c
diff options
context:
space:
mode:
authorBen Smithurst <ben@FreeBSD.org>2001-01-05 22:09:53 +0000
committerBen Smithurst <ben@FreeBSD.org>2001-01-05 22:09:53 +0000
commitedaff99d578142f0006b5d0879296dcfd24902e1 (patch)
tree30fcd97a647bd70a61ef7677c911f1790922ac2d /usr.bin/printf/printf.c
parentfceac8f0cd9e0aeac36e74667aedf98265b1a058 (diff)
Notes
Diffstat (limited to 'usr.bin/printf/printf.c')
-rw-r--r--usr.bin/printf/printf.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c
index df65f5a886af..4df9dfa06d58 100644
--- a/usr.bin/printf/printf.c
+++ b/usr.bin/printf/printf.c
@@ -58,6 +58,7 @@ static const char rcsid[] =
#ifdef SHELL
#define main printfcmd
#include "bltin/bltin.h"
+#include "memalloc.h"
#else
#define warnx1(a, b, c) warnx(a)
#define warnx2(a, b, c) warnx(a, b)
@@ -245,12 +246,23 @@ mklong(str, ch)
char *str;
int ch;
{
- static char copy[64];
- int len;
+ static char *copy;
+ static size_t copy_size;
+ size_t len, newlen;
+ char *newcopy;
len = strlen(str) + 2;
- if (len > sizeof copy)
- return NULL;
+ if (len > copy_size) {
+ newlen = ((len + 1023) >> 10) << 10;
+#ifdef SHELL
+ if ((newcopy = ckrealloc(copy, newlen)) == NULL)
+#else
+ if ((newcopy = realloc(copy, newlen)) == NULL)
+#endif
+ return (NULL);
+ copy = newcopy;
+ copy_size = newlen;
+ }
memmove(copy, str, len - 3);
copy[len - 3] = 'q';