klibc-bot for Herbert Xu
2020-Mar-28 21:49 UTC
[klibc] [klibc:update-dash] dash: parser: Fix parsing of ${}
Commit-ID: 8dfaea787acb1aaf1387af6a81904e0a57746985 Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=8dfaea787acb1aaf1387af6a81904e0a57746985 Author: Herbert Xu <herbert at gondor.apana.org.au> AuthorDate: Tue, 3 Apr 2018 00:40:25 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sat, 28 Mar 2020 21:42:55 +0000 [klibc] dash: parser: Fix parsing of ${} [ dash commit 6348e861b20d0b90275970af7357ac35ef956f16 ] dash -c 'echo ${}' should print "Bad subtitution" but instead fails with "Syntax error: Missing '}'". This is caused by us reading an extra character beyond the right brace. This patch fixes it so that this construct only fails during expansion rather than during parsing. Fixes: 3df3edd13389 ("[PARSER] Report substition errors at...") 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 6a8a4a43..efa8060f 100644 --- a/usr/dash/parser.c +++ b/usr/dash/parser.c @@ -1262,7 +1262,7 @@ varname: STPUTC(c, out); c = pgetc_eatbnl(); } while (is_digit(c)); - } else { + } else if (c != '}') { int cc = c; c = pgetc_eatbnl(); @@ -1290,7 +1290,8 @@ varname: } USTPUTC(cc, out); - } + } else + goto badsub; if (subtype == 0) { int cc = c;
Maybe Matching Threads
- [klibc:update-dash] parser: Fix parsing of ${}
- [klibc:update-dash] [PARSER] Catch variable length expansions on non-existant specials
- [klibc:update-dash] dash: [PARSER] Catch variable length expansions on non-existant specials
- [klibc:update-dash] [PARSER] Handle backslash newlines properly after dollar sign
- [klibc:update-dash] dash: [PARSER] Handle backslash newlines properly after dollar sign