From c9df6bc8d46415e270273777c80025948762e897 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 10 Sep 2017 18:02:52 +0100 Subject: 41662: exec -a arguments weren't sanitised --- ChangeLog | 8 ++++++++ Src/exec.c | 3 +++ Test/A01grammar.ztst | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/ChangeLog b/ChangeLog index 39f334370..85fa84de5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2017-09-10 Peter Stephenson + + * 41622: Src/exec., Test/A01grammar.ztst: exec -a arguments + weren't sanitised. + + * 41661: Src/subst.c, Test/D04parameter.ztst: need to remove + tokens before passing to bufferwords() for (z). + 2017-09-09 Jun-ichi Takimoto * 41628 (plus 41645 by Oliver): Completion/Unix/Command/_ps: diff --git a/Src/exec.c b/Src/exec.c index 76a6bb1a4..e2432fda4 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3007,6 +3007,9 @@ execcmd_exec(Estate state, Execcmd_params eparams, } if (exec_argv0) { char *str, *s; + exec_argv0 = dupstring(exec_argv0); + remnulargs(exec_argv0); + untokenize(exec_argv0); size_t sz = strlen(exec_argv0); str = s = zalloc(5 + 1 + sz + 1); strcpy(s, "ARGV0="); diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst index 0302c9624..5e7d6acd8 100644 --- a/Test/A01grammar.ztst +++ b/Test/A01grammar.ztst @@ -103,6 +103,12 @@ 0:`exec' with -a option, no space >/bin/SPLOOSH + (exec -a foo* $ZTST_testdir/../Src/zsh -fc 'print -r -- ${(V)0}') + (exec -a "" $ZTST_testdir/../Src/zsh -fc 'print -r -- ${(V)0}') +0:rationalisation of arguments to exec -a +>foo* +> + ( opts=(-a /bin/WHOOOSH) exec $opts /bin/sh -c 'echo $0' -- cgit 1.4.1