From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26689 invoked by alias); 18 Jun 2015 02:48:02 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35514 Received: (qmail 20599 invoked from network); 18 Jun 2015 02:48:01 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.0 X-Helo: d03dlp02.boulder.ibm.com X-MailFrom: hanpt@linux.vnet.ibm.com X-RcptTo: zsh-workers@zsh.org Date: Thu, 18 Jun 2015 10:37:39 +0800 From: Han Pingtian To: zsh-workers@zsh.org Subject: [PATCH] check length before call strncmp in range_type() Message-ID: <20150618023739.GA12344@localhost.localdomain> Mail-Followup-To: zsh-workers@zsh.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15061802-0013-0000-0000-00000E7F3381 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