Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 80b4785

Browse files
rscharfegitster
authored andcommitted
sha1_file: avoid overrunning alternate object base string
While checking if a new alternate object database is a duplicate make sure that old and new base paths have the same length before comparing them with memcmp. This avoids overrunning the buffer of the existing entry if the new one is longer and it stops rejecting foobar/ after foo/ was already added. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7bbc4e8 commit 80b4785

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sha1_file.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ static int link_alt_odb_entry(const char *entry, const char *relative_base, int
303303
* thing twice, or object directory itself.
304304
*/
305305
for (alt = alt_odb_list; alt; alt = alt->next) {
306-
if (!memcmp(ent->base, alt->base, pfxlen)) {
306+
if (pfxlen == alt->name - alt->base - 1 &&
307+
!memcmp(ent->base, alt->base, pfxlen)) {
307308
free(ent);
308309
return -1;
309310
}

0 commit comments

Comments
 (0)