about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2017-05-08 18:00:55 +0100
committerPeter Stephenson <pws@zsh.org>2017-05-08 18:00:55 +0100
commitaf1c82d646d2f1fa9cecbfcffd0159cc3cebe237 (patch)
tree14d2e3c92dec4c12afc753cccd4e8f301823f17f
parent641a764b8203de5e5f5c9f1d6d5b0a48c26ca9e7 (diff)
downloadzsh-af1c82d646d2f1fa9cecbfcffd0159cc3cebe237.tar.gz
zsh-af1c82d646d2f1fa9cecbfcffd0159cc3cebe237.tar.xz
zsh-af1c82d646d2f1fa9cecbfcffd0159cc3cebe237.zip
40173: Off-by-one error checking for {varid}.
This caused a single unprintable character in braces before a
redirection to be treated as an indentifier.
-rw-r--r--ChangeLog3
-rw-r--r--Src/parse.c2
-rw-r--r--Test/A04redirect.ztst9
3 files changed, 13 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 8ac6df15e..bc7f3d7bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2017-05-08  Peter Stephenson  <p.stephenson@samsung.com>
 
+	* 41073: Src/parse.c, Test/A04redirect.ztst: off-by-one error
+	checking for {varid} syntax.
+
 	* users/22688: Src/parse.c, Test/A04redirect.ztst: Allow mixing
 	of redirections and arguments after anonymous functions.
 
diff --git a/Src/parse.c b/Src/parse.c
index b0de9a863..8769baae4 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -1836,7 +1836,7 @@ par_simple(int *cmplx, int nr)
 
 		if (*ptr == Outbrace && ptr > tokstr + 1)
 		{
-		    if (itype_end(tokstr+1, IIDENT, 0) >= ptr - 1)
+		    if (itype_end(tokstr+1, IIDENT, 0) >= ptr)
 		    {
 			char *toksave = tokstr;
 			char *idstring = dupstrpfx(tokstr+1, eptr-tokstr-1);
diff --git a/Test/A04redirect.ztst b/Test/A04redirect.ztst
index 2671080c2..cb82751ce 100644
--- a/Test/A04redirect.ztst
+++ b/Test/A04redirect.ztst
@@ -165,6 +165,15 @@
 ?About to close a second time
 *?\(eval\):*: failed to close file descriptor *
 
+  eval $'fn-varid() { print {\x18}<<0 }'
+  { which -x2 fn-varid; fn-varid } | tr $'\x18' '?'
+0:Regression test for off-by-one in varid check
+>fn-varid () {
+>  print {?} <<0
+>0
+>}
+>{?}
+
   print foo >&-
 0:'>&-' redirection