about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2015-02-20 16:25:47 +0000
committerPeter Stephenson <pws@zsh.org>2015-02-20 16:25:54 +0000
commitb237ba0a8eaa5001283ac8448872021723b90aff (patch)
tree9c7e94bae7f00853ea6ed705229492dd8e9f3f68 /Src
parentdf7a657b10df436e88a4c293cdfa5c7b156fba72 (diff)
downloadzsh-b237ba0a8eaa5001283ac8448872021723b90aff.tar.gz
zsh-b237ba0a8eaa5001283ac8448872021723b90aff.tar.xz
zsh-b237ba0a8eaa5001283ac8448872021723b90aff.zip
34587: ensure multibyte characters don't overflow.
They could start incorporating tokens, with bad karma.

Add test.
Diffstat (limited to 'Src')
-rw-r--r--Src/utils.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Src/utils.c b/Src/utils.c
index 702829c0c..1bcceb091 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -4797,6 +4797,14 @@ mb_metacharlenconv_r(const char *s, wint_t *wcp, mbstate_t *mbsp)
 	    inchar = *++ptr ^ 32;
 	    DPUTS(!*ptr,
 		  "BUG: unexpected end of string in mb_metacharlen()\n");
+	} else if (imeta(*ptr)) {
+	    /*
+	     * As this is metafied input, this is a token --- this
+	     * can't be a part of the string.  It might be
+	     * something on the end of an unbracketed parameter
+	     * reference, for example.
+	     */
+	    break;
 	} else
 	    inchar = *ptr;
 	ptr++;