Skip to content

Commit

Permalink
link_alt_odb_entry: fix read over array bounds reported by valgrind
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Heiko Voigt authored and Junio C Hamano committed Jul 30, 2012
1 parent d0f1ea6 commit cb2912c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ static int link_alt_odb_entry(const char * entry, int len, const char * relative
return -1;
}
}
if (!memcmp(ent->base, objdir, pfxlen)) {
if (!strcmp(ent->base, objdir)) {
free(ent);
return -1;
}
Expand Down

0 comments on commit cb2912c

Please sign in to comment.