Skip to content

Commit 3aa98a6

Browse files
phillipwoodgitster
authored andcommitted
midx: avoid negative array index
nth_midxed_pack_int_id() returns the index of the pack file in the multi pack index's list of packfiles that the specified object. The index is returned as a uint32_t. Storing this in an int will make the index negative if the most significant bit is set. Fix this by using uint32_t as the rest of the code does. This is unlikely to be a practical problem as it requires the multipack index to reference 2^31 packfiles. Signed-off-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f874c0e commit 3aa98a6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

midx-write.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
15661566
_("Counting referenced objects"),
15671567
m->num_objects);
15681568
for (i = 0; i < m->num_objects; i++) {
1569-
int pack_int_id = nth_midxed_pack_int_id(m, i);
1569+
uint32_t pack_int_id = nth_midxed_pack_int_id(m, i);
15701570
count[pack_int_id]++;
15711571
display_progress(progress, i + 1);
15721572
}
@@ -1697,7 +1697,7 @@ static void fill_included_packs_batch(struct repository *r,
16971697

16981698
total_size = 0;
16991699
for (i = 0; total_size < batch_size && i < m->num_packs; i++) {
1700-
int pack_int_id = pack_info[i].pack_int_id;
1700+
uint32_t pack_int_id = pack_info[i].pack_int_id;
17011701
struct packed_git *p = m->packs[pack_int_id];
17021702
uint64_t expected_size;
17031703

0 commit comments

Comments
 (0)