Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] check length before call strncmp in range_type()
- X-seq: zsh-workers 35514
- From: Han Pingtian <hanpt@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] check length before call strncmp in range_type()
- Date: Thu, 18 Jun 2015 10:37:39 +0800
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mail-followup-to: zsh-workers@xxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author