From 0d8e5fbc31e1082063bfb5155c35b7869721152b Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 10 Mar 2026 21:26:55 +0100 Subject: cgit: override die routine globally We don't get any return value from compile_grep_patterns calling compile_regexp_failed, causing the default die routine to print to stderr and then for cgit to exit ungracefully. Instead override the default die routine to show a normal error page. Perhaps compile_grep_patterns ought to change upstream to return an error. But this commit here will handle future issues as well, so perhaps not a bad idea to do anyway. Link: https://lists.zx2c4.com/pipermail/cgit/2026-March/004982.html Link: https://lists.zx2c4.com/pipermail/cgit/2026-March/004983.html Reported-by: Adrian C. Reported-by: Aiden Woodruff Signed-off-by: Jason A. Donenfeld --- cgit.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cgit.c') diff --git a/cgit.c b/cgit.c index c91897a..c4dc94c 100644 --- a/cgit.c +++ b/cgit.c @@ -1058,6 +1058,12 @@ static int calc_ttl(void) return ctx.cfg.cache_repo_ttl; } +static NORETURN void cgit_die_routine(const char *msg, va_list params) +{ + cgit_vprint_error_page(400, "Bad request", msg, params); + exit(0); +} + int cmd_main(int argc, const char **argv) { const char *path; @@ -1065,6 +1071,7 @@ int cmd_main(int argc, const char **argv) cgit_init_filters(); atexit(cgit_cleanup_filters); + set_die_routine(cgit_die_routine); prepare_context(); cgit_repolist.length = 0; -- cgit v1.3