зеркало из https://github.com/microsoft/git.git
Fix possible out-of-bounds array access
If match is "", match[-1] is accessed. Let pathspec_matches return 1 in that case indicating that "" matches everything. Incidently this fixes git-grep'ing in ".". Signed-off-by: Uwe Zeisberger <Uwe_Zeisberger@digi.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Родитель
4170af8232
Коммит
bb9e15a83c
|
@ -29,10 +29,11 @@ static int pathspec_matches(const char **paths, const char *name)
|
|||
int matchlen = strlen(match);
|
||||
const char *cp, *meta;
|
||||
|
||||
if ((matchlen <= namelen) &&
|
||||
!strncmp(name, match, matchlen) &&
|
||||
(match[matchlen-1] == '/' ||
|
||||
name[matchlen] == '\0' || name[matchlen] == '/'))
|
||||
if (!matchlen ||
|
||||
((matchlen <= namelen) &&
|
||||
!strncmp(name, match, matchlen) &&
|
||||
(match[matchlen-1] == '/' ||
|
||||
name[matchlen] == '\0' || name[matchlen] == '/')))
|
||||
return 1;
|
||||
if (!fnmatch(match, name, 0))
|
||||
return 1;
|
||||
|
|
Загрузка…
Ссылка в новой задаче