Date: Sun, 24 Sep 2017 05:03:58 +0000 (UTC) From: Warner Losh <imp@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323963 - head/contrib/one-true-awk Message-ID: <201709240503.v8O53wNS045521@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: imp Date: Sun Sep 24 05:03:57 2017 New Revision: 323963 URL: https://svnweb.freebsd.org/changeset/base/323963 Log: 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 Modified: head/contrib/one-true-awk/lib.c Modified: head/contrib/one-true-awk/lib.c ============================================================================== --- head/contrib/one-true-awk/lib.c Sun Sep 24 03:33:26 2017 (r323962) +++ head/contrib/one-true-awk/lib.c Sun Sep 24 05:03:57 2017 (r323963) @@ -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");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709240503.v8O53wNS045521>