]> git.ipfire.org Git - thirdparty/git.git/commit - midx.c
midx: check size of oid lookup chunk
authorJeff King <peff@peff.net>
Mon, 9 Oct 2023 21:02:03 +0000 (17:02 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 9 Oct 2023 22:55:00 +0000 (15:55 -0700)
commitfc926567ede1f82799ef49dd54aa37b4497a5453
treee673d9a8f88a8ad834b7398ca75a0d37c7ed35e1
parent52e2e8d43dbae8c05b68efd60cde2aacf3a23890
midx: check size of oid lookup chunk

When reading an on-disk multi-pack-index, we take the number of objects
in the midx from the final value of the fanout table. But we just
blindly assume that the chunk containing the actual oid entries is the
correct size. This can lead to us reading out-of-bounds memory if the
lookup chunk is too small (or if the fanout is corrupted; when they
don't agree we cannot tell which one is wrong).

Note that we bump the assignment of m->num_objects into the fanout
parser callback, so that it's set when we parse the lookup table
(otherwise we'd have to manually record the lookup table size and check
it later).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
midx.c
t/t5319-multi-pack-index.sh