Skip to content

Commit 8edd3da

Browse files
ttaylorrgitster
authored andcommitted
pack-bitmap.c: fix broken warning() when missing MIDX'd pack
In commit 44f9fd6 (pack-bitmap.c: check preferred pack validity when opening MIDX bitmap, 2022-05-24) we started opening all packs contained within a MIDX when loading its corresponding bitmap. However, if a pack is missing, then we will emit a warning like: warning: could not open pack pack-$HASH.pack Later on commit f31a17c (pack-bitmap.c: open and store incremental bitmap layers, 2025-03-20) updated this code to work with incremental MIDX bitmaps, but did not adjust the index into the 'pack_names' field. So if there is a pack in an incremental MIDX chain with a pack in a MIDX layer with a non-zero number of packs in its base layer(s) (in other words, any MIDX layer outside of the first one) that cannot be loaded, we will do an out-of-bounds lookup. Adjust the lookup into the 'pack_names' array by the number of packs in the base to prevent a potential SIGSEGV here. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a51f8ad commit 8edd3da

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pack-bitmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
490490
for (i = 0; i < bitmap_git->midx->num_packs + bitmap_git->midx->num_packs_in_base; i++) {
491491
if (prepare_midx_pack(bitmap_repo(bitmap_git), bitmap_git->midx, i)) {
492492
warning(_("could not open pack %s"),
493-
bitmap_git->midx->pack_names[i]);
493+
bitmap_git->midx->pack_names[i - bitmap_git->midx->num_packs_in_base]);
494494
goto cleanup;
495495
}
496496
}

0 commit comments

Comments
 (0)