diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-04-09 23:00:33 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-04-09 23:00:33 +0000 |
commit | 57e746781c6cd836a9564299ef04d2ae4d995f1c (patch) | |
tree | 6f700223120ea64a82cc61b30146e227437da6b7 | |
parent | d68ae08cde969985e3bfcfc21a64f9c78d736fe1 (diff) | |
download | busybox-w32-57e746781c6cd836a9564299ef04d2ae4d995f1c.tar.gz busybox-w32-57e746781c6cd836a9564299ef04d2ae4d995f1c.tar.bz2 busybox-w32-57e746781c6cd836a9564299ef04d2ae4d995f1c.zip |
dont crash if the variable we do substitution on is not set
-rw-r--r-- | shell/hush.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/shell/hush.c b/shell/hush.c index d6f765d6b..ac2410c48 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -2025,18 +2025,20 @@ static int expand_vars_to_list(o_string *output, int n, char *arg, char or_mask) | |||
2025 | debug_printf_expand("%s\n", val); | 2025 | debug_printf_expand("%s\n", val); |
2026 | } else if (exp_off) { | 2026 | } else if (exp_off) { |
2027 | if (exp_op == '%' || exp_op == '#') { | 2027 | if (exp_op == '%' || exp_op == '#') { |
2028 | /* we need to do a pattern match */ | 2028 | if (val) { |
2029 | bool zero; | 2029 | /* we need to do a pattern match */ |
2030 | char *loc; | 2030 | bool zero; |
2031 | scan_t scan = pick_scan(exp_op, *exp_word, &zero); | 2031 | char *loc; |
2032 | if (exp_op == *exp_word) /* ## or %% */ | 2032 | scan_t scan = pick_scan(exp_op, *exp_word, &zero); |
2033 | ++exp_word; | 2033 | if (exp_op == *exp_word) /* ## or %% */ |
2034 | val = dyn_val = xstrdup(val); | 2034 | ++exp_word; |
2035 | loc = scan(dyn_val, exp_word, zero); | 2035 | val = dyn_val = xstrdup(val); |
2036 | if (zero) | 2036 | loc = scan(dyn_val, exp_word, zero); |
2037 | val = loc; | 2037 | if (zero) |
2038 | else | 2038 | val = loc; |
2039 | *loc = '\0'; | 2039 | else |
2040 | *loc = '\0'; | ||
2041 | } | ||
2040 | } else { | 2042 | } else { |
2041 | /* we need to do an expansion */ | 2043 | /* we need to do an expansion */ |
2042 | int exp_test = (!val || (exp_null && !val[0])); | 2044 | int exp_test = (!val || (exp_null && !val[0])); |