From bd919f30aeb45828404899a1524b2028446860bd Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 17 Nov 2013 20:33:57 +0000 Subject: 32001: fix crash on ${:*} and ${:|} --- ChangeLog | 5 +++++ Src/subst.c | 8 ++++++++ Test/D04parameter.ztst | 9 +++++++++ 3 files changed, 22 insertions(+) diff --git a/ChangeLog b/ChangeLog index 87b00c13f..ff7ee20c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-11-17 Peter Stephenson + + * 32001: Src/subst.: fix crash on empty arrays with array + intersection and disjunction. + 2013-11-15 Barton E. Schaefer * Martin Vaeth: 31988: Doc/Makefile.in, Util/helpfiles: remove diff --git a/Src/subst.c b/Src/subst.c index a4df2567f..1059508ef 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -2941,6 +2941,14 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags) } } } + if (vunset) { + if (unset(UNSET)) { + *idend = '\0'; + zerr("%s: parameter not set", idbeg); + return NULL; + } + val = dupstring(""); + } } else { /* no ${...=...} or anything, but possible modifiers. */ /* * Handler ${+...}. TODO: strange, why do we handle this only diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst index bea945971..a8cc93a12 100644 --- a/Test/D04parameter.ztst +++ b/Test/D04parameter.ztst @@ -1551,3 +1551,12 @@ 0:Empty parameter shouldn't cause modifiers to crash the shell > > + +# This used to cause uncontrolled behaviour, but at best +# you got the wrong output so the check is worth it. + args() { print $#; } + args ${:*} + args ${:|} +0:Intersection and disjunction with empty parameters +>0 +>0 -- cgit 1.4.1