diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-07-18 16:02:25 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-07-18 16:02:25 +0200 |
commit | 2e71101e31b8b421cee0107c4136d68b65e3a5d8 (patch) | |
tree | 7133a7b78605cdf71bfde5a8066c4c12918f9184 | |
parent | 8b08d5a502adec2067e3ebf7f27513f75b0b95e8 (diff) | |
download | busybox-w32-2e71101e31b8b421cee0107c4136d68b65e3a5d8.tar.gz busybox-w32-2e71101e31b8b421cee0107c4136d68b65e3a5d8.tar.bz2 busybox-w32-2e71101e31b8b421cee0107c4136d68b65e3a5d8.zip |
hush: fix 'x=; echo ${x:-"$@"}' producing 'BUG in varexp2' message
function old new delta
expand_string_to_string 126 128 +2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/hush.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/shell/hush.c b/shell/hush.c index 534fabbd0..da10a09a8 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -6529,13 +6529,20 @@ static char *expand_string_to_string(const char *str, int EXP_flags, int do_unba | |||
6529 | argv[0] = (char*)str; | 6529 | argv[0] = (char*)str; |
6530 | argv[1] = NULL; | 6530 | argv[1] = NULL; |
6531 | list = expand_variables(argv, EXP_flags | EXP_FLAG_SINGLEWORD); | 6531 | list = expand_variables(argv, EXP_flags | EXP_FLAG_SINGLEWORD); |
6532 | if (HUSH_DEBUG) | 6532 | if (!list[0]) { |
6533 | if (!list[0] || list[1]) | 6533 | /* Example where it happens: |
6534 | bb_error_msg_and_die("BUG in varexp2"); | 6534 | * x=; echo ${x:-"$@"} |
6535 | /* actually, just move string 2*sizeof(char*) bytes back */ | 6535 | */ |
6536 | overlapping_strcpy((char*)list, list[0]); | 6536 | ((char*)list)[0] = '\0'; |
6537 | if (do_unbackslash) | 6537 | } else { |
6538 | unbackslash((char*)list); | 6538 | if (HUSH_DEBUG) |
6539 | if (list[1]) | ||
6540 | bb_error_msg_and_die("BUG in varexp2"); | ||
6541 | /* actually, just move string 2*sizeof(char*) bytes back */ | ||
6542 | overlapping_strcpy((char*)list, list[0]); | ||
6543 | if (do_unbackslash) | ||
6544 | unbackslash((char*)list); | ||
6545 | } | ||
6539 | debug_printf_expand("string_to_string=>'%s'\n", (char*)list); | 6546 | debug_printf_expand("string_to_string=>'%s'\n", (char*)list); |
6540 | return (char*)list; | 6547 | return (char*)list; |
6541 | } | 6548 | } |