commit-graph: check size of oid fanout chunk
commit52e2e8d43dbae8c05b68efd60cde2aacf3a23890
authorJeff King <peff@peff.net>
Mon, 9 Oct 2023 20:59:51 +0000 (9 16:59 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 9 Oct 2023 22:55:00 +0000 (9 15:55 -0700)
tree9a905c9963593bbf5ceff297f65c9f34e5140df9
parente3c9600397bde3dcd2f628ff1eec098f79f79b67
commit-graph: check size of oid fanout chunk

We load the oid fanout chunk with pair_chunk(), which means we never see
the size of the chunk. We just assume the on-disk file uses the
appropriate size, and if it's too small we'll access random memory.

It's easy to check this up-front; the fanout always consists of 256
uint32's, since it is a fanout of the first byte of the hash pointing
into the oid index. These parameters can't be changed without
introducing a new chunk type.

This matches the similar check in the midx OIDF chunk (but note that
rather than checking for the error immediately, the graph code just
leaves parts of the struct NULL and checks for required fields later).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-graph.c
t/t5318-commit-graph.sh