summaryrefslogtreecommitdiff
path: root/contrib/one-true-awk
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2017-09-24 05:03:57 +0000
committerWarner Losh <imp@FreeBSD.org>2017-09-24 05:03:57 +0000
commit547f34cace39b156d68197bf9ecbe0edfeec5084 (patch)
tree11f769648955c583761162d9c9fad3a37ca4eb9f /contrib/one-true-awk
parent27cb792d48174e0f893766e7e9e5544df1a0b9d9 (diff)
downloadsrc-test-547f34cace39b156d68197bf9ecbe0edfeec5084.tar.gz
src-test-547f34cace39b156d68197bf9ecbe0edfeec5084.zip
Fix uninitialized variable
echo | awk 'BEGIN {i=$1; print i}' prints a boatload of stack garbage. NUL terminate the memory returned from malloc to prevent it. Obtained from: OpenBSD run.c 1.40 Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D12379
Notes
Notes: svn path=/head/; revision=323963
Diffstat (limited to 'contrib/one-true-awk')
-rw-r--r--contrib/one-true-awk/lib.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/contrib/one-true-awk/lib.c b/contrib/one-true-awk/lib.c
index 5eeb53d4679db..ff5c95a731aa8 100644
--- a/contrib/one-true-awk/lib.c
+++ b/contrib/one-true-awk/lib.c
@@ -62,6 +62,7 @@ void recinit(unsigned int n)
|| (fldtab = (Cell **) malloc((nfields+1) * sizeof(Cell *))) == NULL
|| (fldtab[0] = (Cell *) malloc(sizeof(Cell))) == NULL )
FATAL("out of space for $0 and fields");
+ *record = '\0';
*fldtab[0] = dollar0;
fldtab[0]->sval = record;
fldtab[0]->nval = tostring("0");