diff options
author | Denys Vlasenko | 2018-07-20 19:29:41 +0200 |
---|---|---|
committer | Denys Vlasenko | 2018-07-20 19:29:41 +0200 |
commit | f36caa4071bbb5bb6d098ced8116accc65370dd8 (patch) | |
tree | 8a3f24530056c38579a3cab42718d9fd5fa03124 /shell/hush.c | |
parent | 4c3c8a1a61e33a8c55991a260ba73d6a75d74810 (diff) | |
download | busybox-f36caa4071bbb5bb6d098ced8116accc65370dd8.zip busybox-f36caa4071bbb5bb6d098ced8116accc65370dd8.tar.gz |
hush: never glob result of dquoted "${v:+/bin/c*}"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/shell/hush.c b/shell/hush.c index dddba5e..4fdd159 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -5994,7 +5994,19 @@ static int encode_then_append_var_plusminus(o_string *output, int n, continue; } #endif - o_addQchr(&dest, ch); + if (dquoted) { + /* Always glob-protect if in dquotes: + * x=x; echo "${x:+/bin/c*}" - prints: /bin/c* + * x=x; echo "${x:+"/bin/c*"}" - prints: /bin/c* + */ + o_addqchr(&dest, ch); + } else { + /* Glob-protect only if char is quoted: + * x=x; echo ${x:+/bin/c*} - prints many filenames + * x=x; echo ${x:+"/bin/c*"} - prints: /bin/c* + */ + o_addQchr(&dest, ch); + } } /* for (;;) */ if (dest.data) { |