From: Han Pingtian <hanpt@linux.vnet.ibm.com>
To: zsh-workers@zsh.org
Subject: [PATCH] check length before call strncmp in range_type()
Date: Thu, 18 Jun 2015 10:37:39 +0800 [thread overview]
Message-ID: <20150618023739.GA12344@localhost.localdomain> (raw)
When called by 'compadd -M 'M:[[:a:]]=[[:b:]] ....', range_type() will
return PP_ALPHA for [:a:] and PP_BLANK for [:b:]. Checking if len equals
the length of items of colon_stuffs first may fix this problem.
---
Src/pattern.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Src/pattern.c b/Src/pattern.c
index 7e07548..8fa1a72 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -1113,8 +1113,8 @@ range_type(char *start, int len)
const char **csp;
for (csp = colon_stuffs; *csp; csp++) {
- if (!strncmp(start, *csp, len))
- return (csp - colon_stuffs) + PP_FIRST;
+ if (strlen(*csp) == len && !strncmp(start, *csp, len))
+ return (csp - colon_stuffs) + PP_FIRST;
}
return PP_UNKWN;
--
1.9.3
reply other threads:[~2015-06-18 2:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150618023739.GA12344@localhost.localdomain \
--to=hanpt@linux.vnet.ibm.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).