summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorHeiko Voigt <hvoigt@hvoigt.net>2012-07-28 15:46:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-07-30 01:02:51 (GMT)
commitcb2912c324477f0d92618ac258c43b2692e870c4 (patch)
tree629364257c36268a88e22a636d6a12258c821b60 /sha1_file.c
parentd0f1ea6003d97e63110fa7d50bb07f546a909b6e (diff)
downloadgit-cb2912c324477f0d92618ac258c43b2692e870c4.zip
git-cb2912c324477f0d92618ac258c43b2692e870c4.tar.gz
git-cb2912c324477f0d92618ac258c43b2692e870c4.tar.bz2
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>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 4f06a0e..a1f3bee 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -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;
}