compat/fnmatch: fix off-by-one character class's length check
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sun, 11 Nov 2012 10:13:57 +0000 (17:13 +0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 20 Nov 2012 20:13:09 +0000 (12:13 -0800)
Character class "xdigit" is the only one that hits 6 character limit
defined by CHAR_CLASS_MAX_LENGTH. All other character classes are 5
character long and therefore never caught by this.

This should make xdigit tests in t3070 pass on Windows.

Reported-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/fnmatch/fnmatch.c

index 9473aed2bbcb91994f166cf66d24459c66ac2fcb..0ff1d273a5839d15a908a4ed90b56d59b151e6e0 100644 (file)
@@ -345,7 +345,7 @@ internal_fnmatch (pattern, string, no_leading_period, flags)
 
                    for (;;)
                      {
-                       if (c1 == CHAR_CLASS_MAX_LENGTH)
+                       if (c1 > CHAR_CLASS_MAX_LENGTH)
                          /* The name is too long and therefore the pattern
                             is ill-formed.  */
                          return FNM_NOMATCH;