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