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

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