Skip to content

Commit 6926633

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 68bdfd7 commit 6926633

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

dir.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,9 @@ int excluded_from_list(const char *pathname,
534534
if (!strcmp_icase(exclude, basename))
535535
return to_exclude;
536536
} 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))
539540
return to_exclude;
540541
} else {
541542
if (fnmatch_icase(exclude, basename, 0) == 0)

0 commit comments

Comments
 (0)