diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2012-10-15 13:24:34 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-10-15 14:57:16 -0700 |
commit | 692663303f67371a2e4af4e3d353b042f754c036 (patch) | |
tree | 6f0f7962d21985454d734a9179f00f4b134d678f /dir.c | |
parent | 68bdfd7cdc634693320486c06400b60abe92302b (diff) | |
download | git-692663303f67371a2e4af4e3d353b042f754c036.tar.gz |
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>
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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) |