Skip to content

Commit 5a3db94

Browse files
committed
Merge branch 'rs/fix-alt-odb-path-comparison' into maint
Code to avoid adding the same alternate object store twice was subtly broken for a long time, but nobody seems to have noticed. * rs/fix-alt-odb-path-comparison: sha1_file: avoid overrunning alternate object base string
2 parents 5c18fde + 80b4785 commit 5a3db94

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
@@ -315,7 +315,8 @@ static int link_alt_odb_entry(const char *entry, const char *relative_base, int
315315
* thing twice, or object directory itself.
316316
*/
317317
for (alt = alt_odb_list; alt; alt = alt->next) {
318-
if (!memcmp(ent->base, alt->base, pfxlen)) {
318+
if (pfxlen == alt->name - alt->base - 1 &&
319+
!memcmp(ent->base, alt->base, pfxlen)) {
319320
free(ent);
320321
return -1;
321322
}

0 commit comments

Comments
 (0)