klibc-bot for Herbert Xu
2019-Jan-25 03:15 UTC
[klibc] [klibc:update-dash] [PARSER] Catch variable length expansions on non-existant specials
Commit-ID: dc3d109d1cac129e5b6d055eab5a8a277fdd06c5 Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=dc3d109d1cac129e5b6d055eab5a8a277fdd06c5 Author: Herbert Xu <herbert at gondor.apana.org.au> AuthorDate: Thu, 30 Oct 2014 11:53:35 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Fri, 25 Jan 2019 02:57:21 +0000 [klibc] [PARSER] Catch variable length expansions on non-existant specials Currently we only check special variable names that follow directly after $ or ${. So errors such as ${#&} are not caught. This patch fixes that by moving the is_special check to just before we print out the special variable name. 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 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/usr/dash/parser.c b/usr/dash/parser.c index 382ddf24..382658e7 100644 --- a/usr/dash/parser.c +++ b/usr/dash/parser.c @@ -1229,8 +1229,7 @@ varname: STPUTC(c, out); c = pgetc_eatbnl(); } while (is_digit(c)); - } - else if (is_special(c)) { + } else { int cc = c; c = pgetc_eatbnl(); @@ -1251,10 +1250,14 @@ varname: } } + if (!is_special(cc)) { + if (subtype == VSLENGTH) + subtype = 0; + goto badsub; + } + USTPUTC(cc, out); } - else - goto badsub; if (subtype == 0) { switch (c) {
Maybe Matching Threads
- [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
- [klibc:update-dash] parser: Fix parsing of ${}
- [klibc:update-dash] dash: parser: Fix parsing of ${}