exclude: stricten a length check in EXC_FLAG_ENDSWITH case
This block of code deals with the "basename" part only, which has the length of "pathlen - (basename - pathname)". Stricten the length check and remove "pathname" from the main expression to avoid confusion. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Oct 15, 2012 at 13:24 UTC
692663303f67371a2e4af4e3d353b042f754c036
1 file changed
+3
-2
dir.c
+3
-2
@@ -534,8 +534,9 @@ int excluded_from_list(const char *pathname,
534
if (!strcmp_icase(exclude, basename))
535
return to_exclude;
536
} else if (x->flags & EXC_FLAG_ENDSWITH) {
537
- if (x->patternlen - 1 <= pathlen &&
538
- !strcmp_icase(exclude + 1, pathname + pathlen - x->patternlen + 1))
537
+ int len = pathlen - (basename - pathname);
538
+ if (x->patternlen - 1 <= len &&
539
+ !strcmp_icase(exclude + 1, basename + len - x->patternlen + 1))
540
return to_exclude;
541
} else {
542
if (fnmatch_icase(exclude, basename, 0) == 0)