midx.c: prevent overflow in `fill_included_packs_batch()`

In a similar spirit as in previous commits, avoid an integer overflow when computing the expected size of a MIDX. (Note that this is also OK as-is, since `p->pack_size` is an `off_t`, so this computation should already be done as 64-bit integers. But again, let's use `st_mult()` to make this fact clear). Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Jul 12, 2023 at 19:37 UTC d67609bdded151d78522911629c9e7da7fd06640
1 file changed +2 -2
midx.c
+2 -2
@@ -1994,8 +1994,8 @@ static int fill_included_packs_batch(struct repository *r,
1994 if (open_pack_index(p) || !p->num_objects)
1995 continue;
1996
1997 - expected_size = (size_t)(p->pack_size
1998 - * pack_info[i].referenced_objects);
1997 + expected_size = st_mult(p->pack_size,
1998 + pack_info[i].referenced_objects);
1999 expected_size /= p->num_objects;
2000
2001 if (expected_size >= batch_size)