aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-02-16 19:02:22 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2020-02-16 19:24:33 +0100
commite368d851e78a2eb2aee50b8bad29dcc301feec65 (patch)
tree7a047d689cc8fe4c0890ad95fb088ecca8df72c3 /shell
parent4ace38580927b3b402b6b35ab50893dbfd5f77c3 (diff)
downloadbusybox-e368d851e78a2eb2aee50b8bad29dcc301feec65.tar.gz
ash: eval: Use the correct expansion mode for fd redirection
Upstream comment: Date: Mon, 19 Nov 2018 18:00:32 +0800 eval: Use the correct expansion mode for fd redirection It has been reported that echo test >&$EMPTY_VARIABLE causes dash to segfault. This is a symptom of the bigger problem that dash tries to perform pathname expansion as well as field splitting on the word after >& and <&. This is wrong and this patch fixes it to use the same expansions as done on a normal redirection. Reported-by: Andrej Shadura <andrew.shadura@collabora.co.uk> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 97c7f4ef5..a43b65680 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -9445,11 +9445,10 @@ expredir(union node *n)
case NFROMFD:
case NTOFD: /* >& */
if (redir->ndup.vname) {
- expandarg(redir->ndup.vname, &fn, EXP_FULL | EXP_TILDE);
+ expandarg(redir->ndup.vname, &fn, EXP_TILDE | EXP_REDIR);
if (fn.list == NULL)
ash_msg_and_raise_error("redir error");
#if BASH_REDIR_OUTPUT
-//FIXME: we used expandarg with different args!
if (!isdigit_str9(fn.list->text)) {
/* >&file, not >&fd */
if (redir->nfile.fd != 1) /* 123>&file - BAD */