diff options
author | 2018-04-24 08:25:16 +0000 | |
---|---|---|
committer | 2018-04-24 08:25:16 +0000 | |
commit | 837faf05a0cfa7138d65e91db32c015aaf7bed78 (patch) | |
tree | a52cef2facb235edf18931a26bcbc154c4f393b7 | |
parent | Make dhclient show imsg pipe poll error messages in debug output only. (diff) | |
download | wireguard-openbsd-837faf05a0cfa7138d65e91db32c015aaf7bed78.tar.xz wireguard-openbsd-837faf05a0cfa7138d65e91db32c015aaf7bed78.zip |
Keep the time pipeline's stack in tact
Revision 1.28 (2008) fixed stack abuse by allocating a new one and
effectively clearing it. This broke pipelines such as
$ time for i in . ; do : ; done
/bin/ksh: : is read only
Prompted by tb, OK millert, tb, jca
-rw-r--r-- | bin/ksh/syn.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/bin/ksh/syn.c b/bin/ksh/syn.c index 690d21321b9..4d845d9eca5 100644 --- a/bin/ksh/syn.c +++ b/bin/ksh/syn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syn.c,v 1.38 2015/12/30 09:07:00 tedu Exp $ */ +/* $OpenBSD: syn.c,v 1.39 2018/04/24 08:25:16 kn Exp $ */ /* * shell parser (C version) @@ -365,9 +365,13 @@ get_command(int cf) syniocf &= ~(KEYWORD|ALIAS); t = pipeline(0); if (t) { - t->str = alloc(2, ATEMP); - t->str[0] = '\0'; /* TF_* flags */ - t->str[1] = '\0'; + if (t->str) { + t->str = str_save(t->str, ATEMP); + } else { + t->str = alloc(2, ATEMP); + t->str[0] = '\0'; /* TF_* flags */ + t->str[1] = '\0'; + } } t = block(TTIME, t, NULL, NULL); break; |