klibc-bot for Herbert Xu
2020-Mar-28 21:49 UTC
[klibc] [klibc:update-dash] dash: parser: Fix parameter expansion inside inner double quotes
Commit-ID: f7cbabef4c6d732406affe8d71b2f53bb24baa2f Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=f7cbabef4c6d732406affe8d71b2f53bb24baa2f Author: Herbert Xu <herbert at gondor.apana.org.au> AuthorDate: Tue, 3 Apr 2018 01:04:55 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sat, 28 Mar 2020 21:42:55 +0000 [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 at googlemail.com> Fixes: ab1cecb40478 (" parser: Add syntax stack for recursive...") Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/dash/parser.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr/dash/parser.c b/usr/dash/parser.c index efa8060f..8e407816 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)),
Apparently Analagous Threads
- [klibc:update-dash] parser: Fix parameter expansion inside inner double quotes
- [klibc:update-dash] parser: Add syntax stack for recursive parsing
- [klibc:update-dash] dash: parser: Add syntax stack for recursive parsing
- [klibc:update-dash] parser: Fix incorrect eating of backslash newlines
- [klibc:update-dash] dash: parser: Fix incorrect eating of backslash newlines