]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit-graph.c: prevent overflow in `write_commit_graph()`
authorTaylor Blau <me@ttaylorr.com>
Wed, 12 Jul 2023 23:38:16 +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 trying to read an existing OID while writing a new commit-graph.

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

index 8333ce8e047810a17da153b79f9f9fae63d854cf..54697e7a4d51929a7f07fd04546f760b08ac0685 100644 (file)
@@ -2454,7 +2454,7 @@ int write_commit_graph(struct object_directory *odb,
                struct commit_graph *g = ctx->r->objects->commit_graph;
                for (i = 0; i < g->num_commits; i++) {
                        struct object_id oid;
-                       oidread(&oid, g->chunk_oid_lookup + g->hash_len * i);
+                       oidread(&oid, g->chunk_oid_lookup + st_mult(g->hash_len, i));
                        oid_array_append(&ctx->oids, &oid);
                }
        }