summaryrefslogtreecommitdiff
path: root/commit.h
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2024-06-14 15:23:58 -0400
committerJunio C Hamano <gitster@pobox.com>2024-06-14 14:19:27 -0700
commita83e21de6b7630c1cdf3298d68b120dd9eaecd0f (patch)
treed8a273a489f8b7bf49a7a60dbd008bf6f6fd3cfa /commit.h
parent20c49432e44f1c98e37f5df97c8137ecd8c1af77 (diff)
pack-bitmap.c: ensure pseudo-merge offset reads are bounded
After reading the pseudo-merge extension's metadata table, we allocate an array to store information about each pseudo-merge, including its byte offset within the .bitmap file itself. This is done like so: pseudo_merge_ofs = index_end - 24 - (index->pseudo_merges.nr * sizeof(uint64_t)); for (i = 0; i < index->pseudo_merges.nr; i++) { index->pseudo_merges.v[i].at = get_be64(pseudo_merge_ofs); pseudo_merge_ofs += sizeof(uint64_t); } But if the pseudo-merge table is corrupt, we'll keep calling get_be64() past the end of the pseudo-merge extension, potentially reading off the end of the mmap'd region. Prevent this by ensuring that we have at least `table_size - 24` many bytes available to read (adding 24 to the left-hand side of our inequality to account for the length of the metadata component). This is sufficient to prevent us from reading off the end of the pseudo-merge extension, and ensures that all of the get_be64() calls below are in bounds. Helped-by: Jeff King <peff@peff.net> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.h')
0 files changed, 0 insertions, 0 deletions