Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
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.
Diffstat (limited to 'source')
| -rw-r--r-- | source/parsing.c | 12 |
1 file changed, 11 insertions, 1 deletion
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; } |
