mirror of
https://github.com/git/git
synced 2024-11-05 18:59:29 +00:00
link_alt_odb_entry: fix read over array bounds reported by valgrind
pfxlen can be longer than the path in objdir when relative_base contains the path to gits object directory. Here we are interested in checking if ent->base[] (the part that corresponds to .git/objects) is the same string as objdir, and the code NUL-terminated ent->base[] to LEADING PATH\0XX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\0 in preparation for these "duplicate check" step (before we return from the function, the first NUL is turned into '/' so that we can fill XX when probing for loose objects). All we need to do is to compare the string with the path to our object directory. Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
d0f1ea6003
commit
cb2912c324
1 changed files with 1 additions and 1 deletions
|
@ -298,7 +298,7 @@ static int link_alt_odb_entry(const char * entry, int len, const char * relative
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!memcmp(ent->base, objdir, pfxlen)) {
|
if (!strcmp(ent->base, objdir)) {
|
||||||
free(ent);
|
free(ent);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue