Blame SOURCES/zsh-5.0.2-noexec-subscript.patch

f686d7
From 2f5bc6482fdddac91a7f06602d65584ebeb41a6c Mon Sep 17 00:00:00 2001
f686d7
From: "Barton E. Schaefer" <schaefer@zsh.org>
f686d7
Date: Wed, 15 Jul 2015 17:51:41 -0700
f686d7
Subject: [PATCH] 35799: with NO_EXEC, parse parameter subscript expressions
f686d7
f686d7
Upstream-commit: a0862f6381979b165e864e9c5b97d12432d35d48
f686d7
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
f686d7
---
f686d7
 Src/params.c | 22 +++++++++++++++-------
f686d7
 1 file changed, 15 insertions(+), 7 deletions(-)
f686d7
f686d7
diff --git a/Src/params.c b/Src/params.c
f686d7
index f7551b2..be8394b 100644
f686d7
--- a/Src/params.c
f686d7
+++ b/Src/params.c
f686d7
@@ -1070,14 +1070,12 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w,
f686d7
     Patprog pprog = NULL;
f686d7
 
f686d7
     /*
f686d7
-     * If in NO_EXEC mode, the parameters won't be set up
f686d7
-     * properly, so there's no point even doing any sanity checking.
f686d7
-     * Just return 0 now.
f686d7
+     * If in NO_EXEC mode, the parameters won't be set up properly,
f686d7
+     * so just pretend everything is a hash for subscript parsing
f686d7
      */
f686d7
-    if (unset(EXECOPT))
f686d7
-	return 0;
f686d7
 
f686d7
-    ishash = (v->pm && PM_TYPE(v->pm->node.flags) == PM_HASHED);
f686d7
+    ishash = (unset(EXECOPT) ||
f686d7
+	      (v->pm && PM_TYPE(v->pm->node.flags) == PM_HASHED));
f686d7
     if (prevcharlen)
f686d7
 	*prevcharlen = 1;
f686d7
     if (nextcharlen)
f686d7
@@ -1232,8 +1230,18 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w,
f686d7
     }
f686d7
     if (!c)
f686d7
 	return 0;
f686d7
-    s = dupstrpfx(s, t - s);
f686d7
     *str = tt = t;
f686d7
+
f686d7
+    /*
f686d7
+     * If in NO_EXEC mode, the parameters won't be set up properly,
f686d7
+     * so there's no additional sanity checking we can do.
f686d7
+     * Just return 0 now.
f686d7
+     */
f686d7
+    if (unset(EXECOPT))
f686d7
+	return 0;
f686d7
+
f686d7
+    s = dupstrpfx(s, t - s);
f686d7
+
f686d7
     /* If we're NOT reverse subscripting, strip the inull()s so brackets *
f686d7
      * are not backslashed after parsestr().  Otherwise leave them alone *
f686d7
      * so that the brackets will be escaped when we patcompile() or when *
f686d7
-- 
f686d7
2.7.4
f686d7