about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2015-07-15 17:51:41 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2015-07-15 17:51:41 -0700
commita0862f6381979b165e864e9c5b97d12432d35d48 (patch)
treec5f6626314b30ee58915047440c98e5522c1f89f
parentb6a2f116a1ebd403b9cd1967a7eae6b634bba6a5 (diff)
downloadzsh-a0862f6381979b165e864e9c5b97d12432d35d48.tar.gz
zsh-a0862f6381979b165e864e9c5b97d12432d35d48.tar.xz
zsh-a0862f6381979b165e864e9c5b97d12432d35d48.zip
35799: with NO_EXEC, parse parameter subscript expressions
-rw-r--r--ChangeLog6
-rw-r--r--Src/params.c22
2 files changed, 21 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 6ee125d8a..7f3ecfbd2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-07-15  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 35799: Src/params.c: with NO_EXEC, parse parameter subscript
+	expressions to correctly balance enclosing braces, but do not
+	perform the subscripting
+
 2015-07-15  Mikael Magnusson  <mikachu@gmail.com>
 
 	* unposted: Completion/Zsh/Type/_ps1234: unposted: _ps1234:
diff --git a/Src/params.c b/Src/params.c
index 3b757359b..7d0c8525e 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -1116,14 +1116,12 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w,
     Patprog pprog = NULL;
 
     /*
-     * If in NO_EXEC mode, the parameters won't be set up
-     * properly, so there's no point even doing any sanity checking.
-     * Just return 0 now.
+     * If in NO_EXEC mode, the parameters won't be set up properly,
+     * so just pretend everything is a hash for subscript parsing
      */
-    if (unset(EXECOPT))
-	return 0;
 
-    ishash = (v->pm && PM_TYPE(v->pm->node.flags) == PM_HASHED);
+    ishash = (unset(EXECOPT) ||
+	      (v->pm && PM_TYPE(v->pm->node.flags) == PM_HASHED));
     if (prevcharlen)
 	*prevcharlen = 1;
     if (nextcharlen)
@@ -1278,8 +1276,18 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w,
     }
     if (!c)
 	return 0;
-    s = dupstrpfx(s, t - s);
     *str = tt = t;
+
+    /*
+     * If in NO_EXEC mode, the parameters won't be set up properly,
+     * so there's no additional sanity checking we can do.
+     * Just return 0 now.
+     */
+    if (unset(EXECOPT))
+	return 0;
+
+    s = dupstrpfx(s, t - s);
+
     /* If we're NOT reverse subscripting, strip the inull()s so brackets *
      * are not backslashed after parsestr().  Otherwise leave them alone *
      * so that the brackets will be escaped when we patcompile() or when *