diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2018-04-03 01:04:55 +0800 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2020-03-28 21:42:55 +0000 |
commit | f7cbabef4c6d732406affe8d71b2f53bb24baa2f (patch) | |
tree | 529e1cdbd959bfac2ada89a24a99e5f9c6d00ecf | |
parent | 8dfaea787acb1aaf1387af6a81904e0a57746985 (diff) | |
download | klibc-f7cbabef4c6d732406affe8d71b2f53bb24baa2f.tar.gz |
[klibc] dash: parser: Fix parameter expansion inside inner double quotes
[ dash commit 48ca00863af909461d1372998bb90549f27abaaf ]
The parsing of parameter expansion inside inner double quotes
breaks because we never look for ENDVAR while innerdq is true.
echo "${x#"${x+''}"''}
This patch fixes it by pushing the syntax stack if innerdq is
true and we enter a new parameter expansion.
This patch also fixes a corner case where a bad substitution error
occurs within arithmetic expansion.
Reported-by: Denys Vlasenko <vda.linux@googlemail.com>
Fixes: ab1cecb40478 (" parser: Add syntax stack for recursive...")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | usr/dash/parser.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/usr/dash/parser.c b/usr/dash/parser.c index efa8060ffc72f..8e4078162b85d 100644 --- a/usr/dash/parser.c +++ b/usr/dash/parser.c @@ -1325,10 +1325,11 @@ badsub: pungetc(); } - if (newsyn == ARISYNTAX && subtype > VSNORMAL) + if (newsyn == ARISYNTAX) newsyn = DQSYNTAX; - if (newsyn != synstack->syntax) { + if ((newsyn != synstack->syntax || synstack->innerdq) && + subtype != VSNORMAL) { synstack_push(&synstack, synstack->prev ?: alloca(sizeof(*synstack)), |