diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-14 14:23:45 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-14 14:23:45 +0200 |
commit | 452cc1d9bdd7848e960919916de7c405512cad05 (patch) | |
tree | 4608e49484ea7438ef17979d5de2f7c5edb3838b | |
parent | 647d8afe869b40c617d2a327b51947cee07b58f3 (diff) | |
download | busybox-w32-452cc1d9bdd7848e960919916de7c405512cad05.tar.gz busybox-w32-452cc1d9bdd7848e960919916de7c405512cad05.tar.bz2 busybox-w32-452cc1d9bdd7848e960919916de7c405512cad05.zip |
ash: [PARSER] Catch variable length expansions on non-existant specials
Upstream commit:
Date: Thu, 30 Oct 2014 11:53:35 +0800
[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@gondor.apana.org.au>
function old new delta
readtoken1 2630 2635 +5
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/shell/ash.c b/shell/ash.c index 15c7c325a..1917b552c 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -12119,7 +12119,7 @@ parsesub: { | |||
12119 | STPUTC(c, out); | 12119 | STPUTC(c, out); |
12120 | c = pgetc_eatbnl(); | 12120 | c = pgetc_eatbnl(); |
12121 | } while (isdigit(c)); | 12121 | } while (isdigit(c)); |
12122 | } else if (is_special(c)) { | 12122 | } else { |
12123 | /* $[{[#]]<specialchar>[}] */ | 12123 | /* $[{[#]]<specialchar>[}] */ |
12124 | int cc = c; | 12124 | int cc = c; |
12125 | 12125 | ||
@@ -12137,10 +12137,16 @@ parsesub: { | |||
12137 | cc = '#'; | 12137 | cc = '#'; |
12138 | } | 12138 | } |
12139 | } | 12139 | } |
12140 | |||
12141 | if (!is_special(cc)) { | ||
12142 | if (subtype == VSLENGTH) | ||
12143 | subtype = 0; | ||
12144 | goto badsub; | ||
12145 | } | ||
12146 | |||
12140 | USTPUTC(cc, out); | 12147 | USTPUTC(cc, out); |
12141 | } else { | ||
12142 | goto badsub; | ||
12143 | } | 12148 | } |
12149 | |||
12144 | if (c != '}' && subtype == VSLENGTH) { | 12150 | if (c != '}' && subtype == VSLENGTH) { |
12145 | /* ${#VAR didn't end with } */ | 12151 | /* ${#VAR didn't end with } */ |
12146 | goto badsub; | 12152 | goto badsub; |