Browse Source

compat/fnmatch: fix off-by-one character class's length check

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>
maint
Nguyễn Thái Ngọc Duy 12 years ago committed by Junio C Hamano
parent
commit
f10e3864dc
  1. 2
      compat/fnmatch/fnmatch.c

2
compat/fnmatch/fnmatch.c

@ -345,7 +345,7 @@ internal_fnmatch (pattern, string, no_leading_period, flags) @@ -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;

Loading…
Cancel
Save