[klibc] [klibc:update-dash] dash: eval: Use the correct expansion mode for fd redirection

klibc-bot for Herbert Xu herbert at gondor.apana.org.au
Sat Mar 28 14:49:34 PDT 2020

Commit-ID:  60413cc28c9b0b423e89fefff476d39c1926d6da
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=60413cc28c9b0b423e89fefff476d39c1926d6da
Author:     Herbert Xu <herbert at gondor.apana.org.au>
AuthorDate: Mon, 19 Nov 2018 18:00:32 +0800
Committer:  Ben Hutchings <ben at decadent.org.uk>
CommitDate: Sat, 28 Mar 2020 21:42:55 +0000

[klibc] dash: eval: Use the correct expansion mode for fd redirection

[ dash commit 70712c93c40a322056dafce7cbb45c727400936b ]

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

Reported-by: Andrej Shadura <andrew.shadura at collabora.co.uk>
Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>

 usr/dash/eval.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr/dash/eval.c b/usr/dash/eval.c
index dc0c9fa2..4981f156 100644
--- a/usr/dash/eval.c
+++ b/usr/dash/eval.c
@@ -529,7 +529,7 @@ 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);
 				fixredir(redir, fn.list->text, 1);

More information about the klibc mailing list