aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2014-10-30 11:53:35 +0800
committerBen Hutchings <ben@decadent.org.uk>2020-03-28 21:42:54 +0000
commitda8fe1346c93b339333207adecd8493ca1cb403a (patch)
treea9cc123991d6b9cc75a9f746f198ee53a7999321
parenta5a6a6ba303805417242138104643d8c40d71d00 (diff)
downloadklibc-da8fe1346c93b339333207adecd8493ca1cb403a.tar.gz
[klibc] dash: [PARSER] Catch variable length expansions on non-existant specials
[ dash commit cbd6165076cbbf18e68a292f80c1d454fdbedc22 ] 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@gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--usr/dash/parser.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/usr/dash/parser.c b/usr/dash/parser.c
index 382ddf244b60d..382658e7ea9c2 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) {