]> git.ipfire.org Git - thirdparty/git.git/commit
commit-graph.c: prevent overflow in `fill_commit_graph_info()`
authorTaylor Blau <me@ttaylorr.com>
Wed, 12 Jul 2023 23:38:03 +0000 (19:38 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 14 Jul 2023 16:32:03 +0000 (09:32 -0700)
commit2740ed1c76df769aa1c6e75020ace72e2cc2e47f
tree2fdbc6edac4607bd526820b781628f31e53ad9b9
parent0bd8f30a0e4e474163eb2d8dc3020d51ec3c8a35
commit-graph.c: prevent overflow in `fill_commit_graph_info()`

In a similar spirit as previous commits, ensure that we don't overflow
in a few spots within `fill_commit_graph_info()`:

  - First, when computing an offset into the commit data chunk, which
    can occur when the `lex_index` of the item we're looking up exceeds
    2^32-1/GRAPH_DATA_WIDTH.

  - A similar issue when computing the generation date offset for
    commits with `lex_index` greater than 2^32-1/4. Note that in
    practice this will never overflow, since the left-hand operand is
    from calling `sizeof(...)` and is thus already a `size_t`. But wrap
    that in an `st_mult()` to make it clear that we intend to perform
    this computation using 64-bit operands.

  - Finally, a nearly identical issue as above when computing an offset
    into the `generation_data_overflow` chunk.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-graph.c