aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2009-04-02 16:55:38 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2009-04-02 16:55:38 +0000
commitf328e00b107564569ee31820a49540c5dbe34f73 (patch)
treec7494feac252035a03493d188fab67a58a113862
parent2f1d394214c968181e9ab320f2c66f905f8352cf (diff)
downloadbusybox-f328e00b107564569ee31820a49540c5dbe34f73.tar.gz
hush: do not inadvertently parse $((1 + "22")) as ok.
-20 bytes code size
-rw-r--r--shell/hush.c24
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 {
CHAR_ORDINARY = 0,
CHAR_ORDINARY_IF_QUOTED = 1, /* example: *, # */
CHAR_IFS = 2, /* treated as ordinary if quoted */
- CHAR_SPECIAL = 3, /* example: $ */
+ CHAR_SPECIAL = 3, /* \, $, ", maybe ` */
};
enum {
@@ -4160,17 +4160,7 @@ static int parse_stream_dquoted(o_string *dest, struct in_str *input, int dquote
}
debug_printf_parse(": ch=%c (%d) m=%d quote=%d\n",
ch, ch, m, dest->o_quote);
- if (m != CHAR_SPECIAL) {
- o_addQchr(dest, ch);
- if ((dest->o_assignment == MAYBE_ASSIGNMENT
- || dest->o_assignment == WORD_IS_KEYWORD)
- && ch == '='
- && is_assignment(dest->data)
- ) {
- dest->o_assignment = DEFINITELY_ASSIGNMENT;
- }
- goto again;
- }
+ /* Basically, checking every CHAR_SPECIAL char except '"' */
if (ch == '\\') {
if (next == EOF) {
syntax("\\<eof>");
@@ -4208,9 +4198,17 @@ static int parse_stream_dquoted(o_string *dest, struct in_str *input, int dquote
add_till_backquote(dest, input);
o_addchr(dest, SPECIAL_VAR_SYMBOL);
//debug_printf_subst("SUBST RES3 '%s'\n", dest->data + pos);
- /* fall through */
+ goto again;
}
#endif
+ o_addQchr(dest, ch);
+ if (ch == '='
+ && (dest->o_assignment == MAYBE_ASSIGNMENT
+ || dest->o_assignment == WORD_IS_KEYWORD)
+ && is_assignment(dest->data)
+ ) {
+ dest->o_assignment = DEFINITELY_ASSIGNMENT;
+ }
goto again;
}