Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/midx.c
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2023-07-13 02:37:49 +0300
committerJunio C Hamano <gitster@pobox.com>2023-07-14 19:32:03 +0300
commitd67609bdded151d78522911629c9e7da7fd06640 (patch)
treedd8789ffb281f83b3625b78dc7835740b9bb506a /midx.c
parent2bc764c1d4d1bc12ba7d95ceebb0da54ba381be5 (diff)
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>
Diffstat (limited to 'midx.c')
-rw-r--r--midx.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/midx.c b/midx.c
index 606e3ae79e..067482a98c 100644
--- a/midx.c
+++ b/midx.c
@@ -1994,8 +1994,8 @@ static int fill_included_packs_batch(struct repository *r,
if (open_pack_index(p) || !p->num_objects)
continue;
- expected_size = (size_t)(p->pack_size
- * pack_info[i].referenced_objects);
+ expected_size = st_mult(p->pack_size,
+ pack_info[i].referenced_objects);
expected_size /= p->num_objects;
if (expected_size >= batch_size)