diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2009-04-02 16:55:38 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2009-04-02 16:55:38 +0000 |
commit | f328e00b107564569ee31820a49540c5dbe34f73 (patch) | |
tree | c7494feac252035a03493d188fab67a58a113862 | |
parent | 2f1d394214c968181e9ab320f2c66f905f8352cf (diff) | |
download | busybox-w32-f328e00b107564569ee31820a49540c5dbe34f73.tar.gz busybox-w32-f328e00b107564569ee31820a49540c5dbe34f73.tar.bz2 busybox-w32-f328e00b107564569ee31820a49540c5dbe34f73.zip |
hush: do not inadvertently parse $((1 + "22")) as ok.
-20 bytes code size
-rw-r--r-- | shell/hush.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/shell/hush.c b/shell/hush.c index 64b6e87e8..0bddc9213 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -432,7 +432,7 @@ enum { | |||
432 | CHAR_ORDINARY = 0, | 432 | CHAR_ORDINARY = 0, |
433 | CHAR_ORDINARY_IF_QUOTED = 1, /* example: *, # */ | 433 | CHAR_ORDINARY_IF_QUOTED = 1, /* example: *, # */ |
434 | CHAR_IFS = 2, /* treated as ordinary if quoted */ | 434 | CHAR_IFS = 2, /* treated as ordinary if quoted */ |
435 | CHAR_SPECIAL = 3, /* example: $ */ | 435 | CHAR_SPECIAL = 3, /* \, $, ", maybe ` */ |
436 | }; | 436 | }; |
437 | 437 | ||
438 | enum { | 438 | enum { |
@@ -4160,17 +4160,7 @@ static int parse_stream_dquoted(o_string *dest, struct in_str *input, int dquote | |||
4160 | } | 4160 | } |
4161 | debug_printf_parse(": ch=%c (%d) m=%d quote=%d\n", | 4161 | debug_printf_parse(": ch=%c (%d) m=%d quote=%d\n", |
4162 | ch, ch, m, dest->o_quote); | 4162 | ch, ch, m, dest->o_quote); |
4163 | if (m != CHAR_SPECIAL) { | 4163 | /* Basically, checking every CHAR_SPECIAL char except '"' */ |
4164 | o_addQchr(dest, ch); | ||
4165 | if ((dest->o_assignment == MAYBE_ASSIGNMENT | ||
4166 | || dest->o_assignment == WORD_IS_KEYWORD) | ||
4167 | && ch == '=' | ||
4168 | && is_assignment(dest->data) | ||
4169 | ) { | ||
4170 | dest->o_assignment = DEFINITELY_ASSIGNMENT; | ||
4171 | } | ||
4172 | goto again; | ||
4173 | } | ||
4174 | if (ch == '\\') { | 4164 | if (ch == '\\') { |
4175 | if (next == EOF) { | 4165 | if (next == EOF) { |
4176 | syntax("\\<eof>"); | 4166 | syntax("\\<eof>"); |
@@ -4208,9 +4198,17 @@ static int parse_stream_dquoted(o_string *dest, struct in_str *input, int dquote | |||
4208 | add_till_backquote(dest, input); | 4198 | add_till_backquote(dest, input); |
4209 | o_addchr(dest, SPECIAL_VAR_SYMBOL); | 4199 | o_addchr(dest, SPECIAL_VAR_SYMBOL); |
4210 | //debug_printf_subst("SUBST RES3 '%s'\n", dest->data + pos); | 4200 | //debug_printf_subst("SUBST RES3 '%s'\n", dest->data + pos); |
4211 | /* fall through */ | 4201 | goto again; |
4212 | } | 4202 | } |
4213 | #endif | 4203 | #endif |
4204 | o_addQchr(dest, ch); | ||
4205 | if (ch == '=' | ||
4206 | && (dest->o_assignment == MAYBE_ASSIGNMENT | ||
4207 | || dest->o_assignment == WORD_IS_KEYWORD) | ||
4208 | && is_assignment(dest->data) | ||
4209 | ) { | ||
4210 | dest->o_assignment = DEFINITELY_ASSIGNMENT; | ||
4211 | } | ||
4214 | goto again; | 4212 | goto again; |
4215 | } | 4213 | } |
4216 | 4214 | ||