commit-graph.c: prevent overflow in `verify_commit_graph()`
In a similar spirit as previous commits, ensure that we don't overflow when trying to read an OID out of an existing commit-graph during verification. 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
9a25cad7e0228bfd16f2c41b34e9d71a4217085c
1 file changed
+2
-2
commit-graph.c
+2
-2
@@ -2585,7 +2585,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
2585
for (i = 0; i < g->num_commits; i++) {
2586
struct commit *graph_commit;
2587
2588
- oidread(&cur_oid, g->chunk_oid_lookup + g->hash_len * i);
2588
+ oidread(&cur_oid, g->chunk_oid_lookup + st_mult(g->hash_len, i));
2589
2590
if (i && oidcmp(&prev_oid, &cur_oid) >= 0)
2591
graph_report(_("commit-graph has incorrect OID order: %s then %s"),
@@ -2633,7 +2633,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
2633
timestamp_t generation;
2634
2635
display_progress(progress, i + 1);
2636
- oidread(&cur_oid, g->chunk_oid_lookup + g->hash_len * i);
2636
+ oidread(&cur_oid, g->chunk_oid_lookup + st_mult(g->hash_len, i));
2637
2638
graph_commit = lookup_commit(r, &cur_oid);
2639
odb_commit = (struct commit *)create_object(r, &cur_oid, alloc_commit_node(r));