]> git.99rst.org Git - git.git/commitdiff
commit-graph.c: prevent overflow in `load_tree_for_commit()`
authorTaylor Blau <redacted>
Wed, 12 Jul 2023 23:38:08 +0000 (19:38 -0400)
committerJunio C Hamano <redacted>
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 <redacted>
Signed-off-by: Junio C Hamano <redacted>
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));
git clone https://git.99rst.org/PROJECT