[klibc] [klibc:update-dash] parser: Fix parameter expansion inside inner double quotes

klibc-bot for Herbert Xu herbert at gondor.apana.org.au
Thu Jan 24 19:16:00 PST 2019


Commit-ID:  101798c92a7ef3f9d3fc34afc7b0bc4fbfb42caf
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=101798c92a7ef3f9d3fc34afc7b0bc4fbfb42caf
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: Fri, 25 Jan 2019 02:57:21 +0000

[klibc] parser: Fix parameter expansion inside inner double quotes

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)),


More information about the klibc mailing list