aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-02-22 17:26:23 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2020-02-22 17:26:23 +0100
commitc08993f40c0c6c7bdf453e77c3aa9dae8ec0dad9 (patch)
tree01a44b93192180ac09ba94016f05e9ba8db15fc9
parent9a1a659707a18c29166c3e2977523102866d7aed (diff)
downloadbusybox-w32-c08993f40c0c6c7bdf453e77c3aa9dae8ec0dad9.tar.gz
busybox-w32-c08993f40c0c6c7bdf453e77c3aa9dae8ec0dad9.tar.bz2
busybox-w32-c08993f40c0c6c7bdf453e77c3aa9dae8ec0dad9.zip
ash: parser: Do not push token back before parseheredoc
Upstream commit: Date: Mon, 19 Nov 2018 18:43:58 +0800 parser: Do not push token back before parseheredoc When we read the first token in list() we use peektoken instead of readtoken as the following code needs to use the same token again. However, this is wrong when we're in a here-document as it will clobber the saved token without resetting the tokpushback flag. This patch fixes it by doing the tokpushback after parseheredoc and setting lasttoken again if parseheredoc was called. Reported-by: Ron Yorston <rmy@frippery.org> Fixes: 7c245aa8ed33 ("[PARSER] Simplify EOF/newline handling in...") Fixes: ee5cbe9fd6bc ("[SHELL] Optimize dash -c "command" to avoid a fork") Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Tested-by: Simon Ser <contact@emersion.fr> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 83cac3fb0..5fb67c0fa 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -11607,7 +11607,7 @@ list(int nlflag)
11607 11607
11608 n1 = NULL; 11608 n1 = NULL;
11609 for (;;) { 11609 for (;;) {
11610 switch (peektoken()) { 11610 switch (readtoken()) {
11611 case TNL: 11611 case TNL:
11612 if (!(nlflag & 1)) 11612 if (!(nlflag & 1))
11613 break; 11613 break;
@@ -11618,9 +11618,12 @@ list(int nlflag)
11618 if (!n1 && (nlflag & 1)) 11618 if (!n1 && (nlflag & 1))
11619 n1 = NODE_EOF; 11619 n1 = NODE_EOF;
11620 parseheredoc(); 11620 parseheredoc();
11621 tokpushback++;
11622 lasttoken = TEOF;
11621 return n1; 11623 return n1;
11622 } 11624 }
11623 11625
11626 tokpushback++;
11624 checkkwd = CHKNL | CHKKWD | CHKALIAS; 11627 checkkwd = CHKNL | CHKKWD | CHKALIAS;
11625 if (nlflag == 2 && ((1 << peektoken()) & tokendlist)) 11628 if (nlflag == 2 && ((1 << peektoken()) & tokendlist))
11626 return n1; 11629 return n1;