summaryrefslogtreecommitdiff
path: root/usr.bin/awk/tran.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2020-06-10 21:05:03 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2020-06-10 21:05:03 +0000
commit7b05182efa62f2da176b0bf28e1aea87187b8d7c (patch)
tree5541f597b204ae3f1b2c9e2b4d1f1e41bd48c52e /usr.bin/awk/tran.c
parentb1b4a48f2797b1fa13766a126a0c0ef1e1fbc965 (diff)
Update awk to Jan 31, 2020 version.
Diffstat (limited to 'usr.bin/awk/tran.c')
-rw-r--r--usr.bin/awk/tran.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/awk/tran.c b/usr.bin/awk/tran.c
index 0318be0c57d..8e8b755f9bb 100644
--- a/usr.bin/awk/tran.c
+++ b/usr.bin/awk/tran.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tran.c,v 1.25 2020/06/10 21:04:40 millert Exp $ */
+/* $OpenBSD: tran.c,v 1.26 2020/06/10 21:05:02 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -529,12 +529,14 @@ Cell *catstr(Cell *a, Cell *b) /* concatenate a and b */
if (p == NULL)
FATAL("out of space concatenating %s and %s", sa, sb);
snprintf(p, l, "%s%s", sa, sb);
- char *newbuf = malloc(strlen(p) + 2);
+
+ l++; // add room for ' '
+ char *newbuf = malloc(l);
if (newbuf == NULL)
FATAL("out of space concatenating %s and %s", sa, sb);
// See string() in lex.c; a string "xx" is stored in the symbol
// table as "xx ".
- sprintf(newbuf, "%s ", p);
+ snprintf(newbuf, l, "%s ", p);
c = setsymtab(newbuf, p, 0.0, CON|STR|DONTFREE, symtab);
free(p);
free(newbuf);