Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] check length before call strncmp in range_type()



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