diff options
-rw-r--r-- | shell/hush.c | 45 | ||||
-rwxr-xr-x | shell/hush_leaktool.sh | 16 | ||||
-rw-r--r-- | shell/hush_test/hush-trap/catch.right | 1 | ||||
-rwxr-xr-x | shell/hush_test/hush-z_slow/leak_all1.tests | 2 |
4 files changed, 42 insertions, 22 deletions
diff --git a/shell/hush.c b/shell/hush.c index c542b7dd9..2c2750fc8 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -4459,10 +4459,6 @@ static int done_word(o_string *word, struct parse_context *ctx) | |||
4459 | } | 4459 | } |
4460 | } | 4460 | } |
4461 | command->argv = add_string_to_strings(command->argv, xstrdup(word->data)); | 4461 | command->argv = add_string_to_strings(command->argv, xstrdup(word->data)); |
4462 | //SEGV, but good idea. | ||
4463 | // command->argv = add_string_to_strings(command->argv, word->data); | ||
4464 | // word->data = NULL; | ||
4465 | // word->length = 0; | ||
4466 | debug_print_strings("word appended to argv", command->argv); | 4462 | debug_print_strings("word appended to argv", command->argv); |
4467 | } | 4463 | } |
4468 | 4464 | ||
@@ -5481,14 +5477,16 @@ static struct pipe *parse_stream(char **pstring, | |||
5481 | * } is an ordinary char in this case, even inside { cmd; } | 5477 | * } is an ordinary char in this case, even inside { cmd; } |
5482 | * Pathological example: { ""}; } should exec "}" cmd | 5478 | * Pathological example: { ""}; } should exec "}" cmd |
5483 | */ | 5479 | */ |
5484 | if (ch == '}' | 5480 | if (ch == '}') { |
5485 | && !(IS_NULL_PIPE(ctx.pipe) | 5481 | if (!IS_NULL_CMD(ctx.command) /* cmd } */ |
5486 | && IS_NULL_CMD(ctx.command) | 5482 | || dest.length != 0 /* word} */ |
5487 | && dest.length == 0 | 5483 | || dest.o_quoted /* ""} */ |
5488 | && !dest.o_quoted | 5484 | ) { |
5489 | ) | 5485 | goto ordinary_char; |
5490 | ) { | 5486 | } |
5491 | goto ordinary_char; | 5487 | if (!IS_NULL_PIPE(ctx.pipe)) /* cmd | } */ |
5488 | goto skip_end_trigger; | ||
5489 | /* else: } does terminate a group */ | ||
5492 | } | 5490 | } |
5493 | 5491 | ||
5494 | if (end_trigger && end_trigger == ch | 5492 | if (end_trigger && end_trigger == ch |
@@ -5531,6 +5529,7 @@ static struct pipe *parse_stream(char **pstring, | |||
5531 | return ctx.list_head; | 5529 | return ctx.list_head; |
5532 | } | 5530 | } |
5533 | } | 5531 | } |
5532 | skip_end_trigger: | ||
5534 | if (is_ifs) | 5533 | if (is_ifs) |
5535 | continue; | 5534 | continue; |
5536 | 5535 | ||
@@ -6420,12 +6419,11 @@ static int builtin_export(char **argv) | |||
6420 | } | 6419 | } |
6421 | 6420 | ||
6422 | do { | 6421 | do { |
6423 | const char *value; | ||
6424 | char *name = *argv; | 6422 | char *name = *argv; |
6425 | 6423 | ||
6426 | value = strchr(name, '='); | 6424 | /* So far we do not check that name is valid */ |
6427 | if (!value) { | 6425 | if (strchr(name, '=') == NULL) { |
6428 | /* They are exporting something without a =VALUE */ | 6426 | /* Exporting a name without a =VALUE */ |
6429 | struct variable *var; | 6427 | struct variable *var; |
6430 | 6428 | ||
6431 | var = get_local_var(name); | 6429 | var = get_local_var(name); |
@@ -6433,12 +6431,19 @@ static int builtin_export(char **argv) | |||
6433 | var->flg_export = 1; | 6431 | var->flg_export = 1; |
6434 | debug_printf_env("%s: putenv '%s'\n", __func__, var->varstr); | 6432 | debug_printf_env("%s: putenv '%s'\n", __func__, var->varstr); |
6435 | putenv(var->varstr); | 6433 | putenv(var->varstr); |
6434 | continue; | ||
6436 | } | 6435 | } |
6437 | /* bash does not return an error when trying to export | 6436 | /* Exporting non-existing variable. |
6438 | * an undefined variable. Do likewise. */ | 6437 | * bash does not put it in environment, |
6439 | continue; | 6438 | * but remembers that it is exported, |
6439 | * and does put it in env when it is set later. | ||
6440 | * We just set it to "" and export. */ | ||
6441 | name = xasprintf("%s=", name); | ||
6442 | } else { | ||
6443 | /* Exporting VAR=VALUE */ | ||
6444 | name = xstrdup(name); | ||
6440 | } | 6445 | } |
6441 | set_local_var(xstrdup(name), 1, 0); | 6446 | set_local_var(name, 1, 0); |
6442 | } while (*++argv); | 6447 | } while (*++argv); |
6443 | 6448 | ||
6444 | return EXIT_SUCCESS; | 6449 | return EXIT_SUCCESS; |
diff --git a/shell/hush_leaktool.sh b/shell/hush_leaktool.sh index f8e47aecd..ca35ec144 100755 --- a/shell/hush_leaktool.sh +++ b/shell/hush_leaktool.sh | |||
@@ -6,8 +6,20 @@ output=output | |||
6 | freelist=`grep 'free 0x' "$output" | cut -d' ' -f2 | sort | uniq | xargs` | 6 | freelist=`grep 'free 0x' "$output" | cut -d' ' -f2 | sort | uniq | xargs` |
7 | 7 | ||
8 | grep -v free "$output" >"$output.leaked" | 8 | grep -v free "$output" >"$output.leaked" |
9 | |||
10 | i=8 | ||
11 | list= | ||
9 | for freed in $freelist; do | 12 | for freed in $freelist; do |
10 | echo Dropping $freed | 13 | list="$list -e $freed" |
11 | grep -v $freed <"$output.leaked" >"$output.temp" | 14 | test $((--i)) != 0 && continue |
15 | echo Dropping $list | ||
16 | grep -F -v $list <"$output.leaked" >"$output.temp" | ||
12 | mv "$output.temp" "$output.leaked" | 17 | mv "$output.temp" "$output.leaked" |
18 | i=8 | ||
19 | list= | ||
13 | done | 20 | done |
21 | if test "$list"; then | ||
22 | echo Dropping $list | ||
23 | grep -F -v $list <"$output.leaked" >"$output.temp" | ||
24 | mv "$output.temp" "$output.leaked" | ||
25 | fi | ||
diff --git a/shell/hush_test/hush-trap/catch.right b/shell/hush_test/hush-trap/catch.right index 9e34c4c49..80a062c4b 100644 --- a/shell/hush_test/hush-trap/catch.right +++ b/shell/hush_test/hush-trap/catch.right | |||
@@ -2,3 +2,4 @@ sending USR2 | |||
2 | caught | 2 | caught |
3 | sending USR2 | 3 | sending USR2 |
4 | sending USR2 | 4 | sending USR2 |
5 | USR2 | ||
diff --git a/shell/hush_test/hush-z_slow/leak_all1.tests b/shell/hush_test/hush-z_slow/leak_all1.tests index 21fdb0d1e..17ce0c6fa 100755 --- a/shell/hush_test/hush-z_slow/leak_all1.tests +++ b/shell/hush_test/hush-z_slow/leak_all1.tests | |||
@@ -67,6 +67,7 @@ HERE | |||
67 | f >/dev/null | 67 | f >/dev/null |
68 | : $((i++)) | 68 | : $((i++)) |
69 | done | 69 | done |
70 | unset -f f | ||
70 | 71 | ||
71 | memleak | 72 | memleak |
72 | 73 | ||
@@ -133,6 +134,7 @@ HERE | |||
133 | f >/dev/null | 134 | f >/dev/null |
134 | : $((i++)) | 135 | : $((i++)) |
135 | done | 136 | done |
137 | unset -f f | ||
136 | 138 | ||
137 | 139 | ||
138 | memleak | 140 | memleak |