commit-graph.c: prevent overflow in `load_tree_for_commit()`
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>
Taylor Blau committed
Jul 12, 2023 at 19:38 UTC
51c31a6408c1eae3ad6c2f78ec136c1b415cad72
1 file changed
+1
-1
commit-graph.c
+1
-1
@@ -980,7 +980,7 @@ static struct tree *load_tree_for_commit(struct repository *r,
980
g = g->base_graph;
981
982
commit_data = g->chunk_commit_data +
983
- GRAPH_DATA_WIDTH * (graph_pos - g->num_commits_in_base);
983
+ st_mult(GRAPH_DATA_WIDTH, graph_pos - g->num_commits_in_base);
984
985
oidread(&oid, commit_data);
986
set_commit_tree(c, lookup_tree(r, &oid));