shithub: trueawk

Download patch

ref: 0939e3392b0249d9fd15922aa3844cd65f9b4489
parent: 966fdc9c293ed28fb2243801090801db8894a59a
author: M. Warner Losh <wlosh@netflix.com>
date: Sun Jun 2 11:17:29 EDT 2019

Apply r323963 from FreeBSD (pulling in the fix from OpenBSD)

| 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

--- a/lib.c
+++ b/lib.c
@@ -62,6 +62,7 @@
 	  || (fldtab = (Cell **) malloc((nfields+2) * 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");
--