summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2004-01-05 17:28:49 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2004-01-05 17:28:49 +0000
commit66329cbe4c9842e6515d8a1b07b83b2ef3bcae35 (patch)
treeb5c1819f62f8712f716a0fb3dde04f06bef9590b
parent4274eca07f72cb6967bdc8ed0fa2d27d34d89026 (diff)
downloadzsh-66329cbe4c9842e6515d8a1b07b83b2ef3bcae35.tar.gz
zsh-66329cbe4c9842e6515d8a1b07b83b2ef3bcae35.zip
19336: Src/Zle/compmatch.c: Bug with metafied characters in length of
completion prefix
-rw-r--r--ChangeLog8
-rw-r--r--Src/Zle/compmatch.c9
2 files changed, 16 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 331be409a..77cca38c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2004-01-05 Peter Stephenson <pws@csr.com>
+
+ * 19336: Src/Zle/compmatch.c: Matches were compared in length
+ treating Meta characters as ordinary characters. This could
+ result in a common prefix being truncated immediately after
+ the Meta. This generated an invalid metafied string which
+ could cause the shell to crash.
+
2004-01-05 Wayne Davison <wayned@users.sourceforge.net>
* zsh-users/6969: Src/builtin.c: made an eval of an empty string
diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
index f4c720a87..74b2725eb 100644
--- a/Src/Zle/compmatch.c
+++ b/Src/Zle/compmatch.c
@@ -1584,8 +1584,15 @@ sub_match(Cmdata md, char *str, int len, int sfx)
if (check_cmdata(md, sfx))
return ret;
+ /*
+ * Look for a common prefix. Be careful not to include
+ * a widowed Meta in the prefix. If we do include metafied
+ * characters, at this stage we still need the overall length
+ * including Meta's as separate characters.
+ */
for (l = 0, p = str, q = md->str;
- l < len && l < md->len && p[ind] == q[ind];
+ l < len && l < md->len && p[ind] == q[ind]
+ && (p[ind] != Meta || p[ind+1] == q[ind+1]);
l++, p += add, q += add);
if (l) {