Skip to content

Commit

Permalink
exclude: stricten a length check in EXC_FLAG_ENDSWITH case
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Oct 15, 2012
1 parent 68bdfd7 commit 6926633
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,9 @@ int excluded_from_list(const char *pathname,
if (!strcmp_icase(exclude, basename))
return to_exclude;
} else if (x->flags & EXC_FLAG_ENDSWITH) {
if (x->patternlen - 1 <= pathlen &&
!strcmp_icase(exclude + 1, pathname + pathlen - x->patternlen + 1))
int len = pathlen - (basename - pathname);
if (x->patternlen - 1 <= len &&
!strcmp_icase(exclude + 1, basename + len - x->patternlen + 1))
return to_exclude;
} else {
if (fnmatch_icase(exclude, basename, 0) == 0)
Expand Down

0 comments on commit 6926633

Please sign in to comment.