klibc-bot for Herbert Xu
2019-Jan-25 03:16 UTC
[klibc] [klibc:update-dash] parser: Fix parsing of ${}
Commit-ID: 5e8e1a2d765473c0fe0321576e498fe114b76026 Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=5e8e1a2d765473c0fe0321576e498fe114b76026 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: Fri, 25 Jan 2019 02:57:21 +0000 [klibc] parser: Fix parsing of ${} 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;
Apparently Analagous Threads
- [klibc:update-dash] 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