[PATCH 20/20] commit-graph.c: prevent overflow in `verify_commit_graph()`
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Jul 12, 2023, 23:38 UTC
- Message-ID
- <55fff3eb84d8a70aa370aedaf1057ad292435a67.1689205042.git.me@ttaylorr.com>
- In-Reply-To
- <cover.1689205042.git.me@ttaylorr.com>
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> --- commit-graph.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/commit-graph.c b/commit-graph.c index 20d9296c8b..f7a3f97401 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -2584,7 +2584,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags) for (i = 0; i < g->num_commits; i++) { struct commit *graph_commit; - oidread(&cur_oid, g->chunk_oid_lookup + g->hash_len * i); + oidread(&cur_oid, g->chunk_oid_lookup + st_mult(g->hash_len, i)); if (i && oidcmp(&prev_oid, &cur_oid) >= 0) graph_report(_("commit-graph has incorrect OID order: %s then %s"), @@ -2632,7 +2632,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags) timestamp_t generation; display_progress(progress, i + 1); - oidread(&cur_oid, g->chunk_oid_lookup + g->hash_len * i); + oidread(&cur_oid, g->chunk_oid_lookup + st_mult(g->hash_len, i)); graph_commit = lookup_commit(r, &cur_oid); odb_commit = (struct commit *)create_object(r, &cur_oid, alloc_commit_node(r));
-- 2.41.0.347.g7b976b8871f