]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit-graph.c: prevent overflow in `load_tree_for_commit()`
authorTaylor Blau <me@ttaylorr.com>
Wed, 12 Jul 2023 23:38:08 +0000 (19:38 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 14 Jul 2023 16:32:03 +0000 (09:32 -0700)
In a similar spirit as previous commits, ensure that we don't overflow
when computing an offset into the commit_data chunk when the (relative)
graph position exceeds 2^32-1/GRAPH_DATA_WIDTH.

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

index 5e32063d3dce484de3520011bdc5264f9f97aef3..08d773567f362061d8f88d07dd424e4bca719d97 100644 (file)
@@ -980,7 +980,7 @@ static struct tree *load_tree_for_commit(struct repository *r,
                g = g->base_graph;
 
        commit_data = g->chunk_commit_data +
-                       GRAPH_DATA_WIDTH * (graph_pos - g->num_commits_in_base);
+                       st_mult(GRAPH_DATA_WIDTH, graph_pos - g->num_commits_in_base);
 
        oidread(&oid, commit_data);
        set_commit_tree(c, lookup_tree(r, &oid));