From 1b84b06bc69580427d98e2e7e8e20a99b8bd1f43 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 16:33:01 -1000 Subject: Hold the mailmap to max-blob-size git's read_mailmap_blob inflates the whole blob, so a pusher could make every page of a repository read as much as they liked. git reads a note and the .gitmodules file whole as well, and capping those would mean bounding the lookups where the log, commit and tree pages make them, so the manual names them instead. Nothing tested that mailmap.file and mailmap.blob are ignored either. --- source/parsing.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/parsing.c b/source/parsing.c index f684241..909a288 100644 --- a/source/parsing.c +++ b/source/parsing.c @@ -24,11 +24,21 @@ static int mailmap_read; struct string_list *cgit_mailmap(void) { + struct object_id oid; + size_t size; + if (!ctx.repo || !ctx.repo->enable_mailmap) return NULL; if (!mailmap_read) { mailmap_read = 1; - read_mailmap_blob(the_repository, &mailmap, "HEAD:.mailmap"); + // git reads the blob whole, so it is held to the same bound as + // every other blob a page inflates. + if ( + !repo_get_oid(the_repository, "HEAD:.mailmap", &oid) && + odb_read_object_info(the_repository->objects, &oid, &size) == OBJ_BLOB && + !cgit_blob_too_large(size) + ) + read_mailmap_blob(the_repository, &mailmap, "HEAD:.mailmap"); } return mailmap.nr ? &mailmap : NULL; } -- cgit 2.12.1