diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2022-09-01 15:21:29 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2022-09-01 15:21:29 +0000 |
commit | 70ae1873615ab6a46b0008d8ed4c7ea153830fd9 (patch) | |
tree | 6ffe565293ec572308c9e85da5b9d9ef06a209e7 /usr.bin/awk/run.c | |
parent | 36b21fa25500f8cfb71ca4a0d5d5c098a93b7eb3 (diff) |
Update awk to Aug 30, 2022 version.
Various leaks and use-after-free issues plugged/fixed.
Diffstat (limited to 'usr.bin/awk/run.c')
-rw-r--r-- | usr.bin/awk/run.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/usr.bin/awk/run.c b/usr.bin/awk/run.c index 860911acc40..055159584c4 100644 --- a/usr.bin/awk/run.c +++ b/usr.bin/awk/run.c @@ -1,4 +1,4 @@ -/* $OpenBSD: run.c,v 1.72 2022/06/03 19:40:56 millert Exp $ */ +/* $OpenBSD: run.c,v 1.73 2022/09/01 15:21:28 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved @@ -972,8 +972,10 @@ int format(char **pbuf, int *pbufsize, const char *s, Node *a) /* printf-like co } *p = '\0'; free(fmt); - for ( ; a; a = a->nnext) /* evaluate any remaining args */ - execute(a); + for ( ; a; a = a->nnext) { /* evaluate any remaining args */ + x = execute(a); + tempfree(x); + } *pbuf = buf; *pbufsize = bufsize; return p - buf; @@ -1269,6 +1271,7 @@ Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[2]); a[3] is type */ origs = s = strdup(getsval(y)); if (s == NULL) FATAL("out of space in split"); + tempfree(y); arg3type = ptoi(a[3]); if (a[2] == NULL) /* fs string */ fs = getsval(fsloc); @@ -1391,7 +1394,6 @@ Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[2]); a[3] is type */ } } tempfree(ap); - tempfree(y); xfree(origs); xfree(origfs); x = gettemp(); @@ -1836,8 +1838,10 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg lis setfval(x, u); if (nextarg != NULL) { WARNING("warning: function has too many arguments"); - for ( ; nextarg; nextarg = nextarg->nnext) - execute(nextarg); + for ( ; nextarg; nextarg = nextarg->nnext) { + y = execute(nextarg); + tempfree(y); + } } return(x); } |