summaryrefslogtreecommitdiff
path: root/bin/ksh
diff options
context:
space:
mode:
authorkn <kn@cvs.openbsd.org>2018-04-24 08:25:17 +0000
committerkn <kn@cvs.openbsd.org>2018-04-24 08:25:17 +0000
commited7b7d6d5cd325c625b76e35bf3df6f92a547719 (patch)
tree232eff71dc66299c98ee2b2f4748c23927a27f89 /bin/ksh
parenta3bd49c6090f549d20b16ae9bb55589bc786ac6b (diff)
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
Diffstat (limited to 'bin/ksh')
-rw-r--r--bin/ksh/syn.c12
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;