From 78a35f93b866a7b37f4a021f3f8b23e80ee0e4e4 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Wed, 15 Jul 2026 17:15:11 -1000 Subject: Tolerate a missing or empty repository URL trim_end() returns NULL when a repo url is empty or all slashes, and the later newline trim dereferenced it. The legacy r= and p=about path also read the last byte of the url without checking it was set. --- source/cmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/cmd.c') diff --git a/source/cmd.c b/source/cmd.c index 7eb642c..aaf5fe5 100644 --- a/source/cmd.c +++ b/source/cmd.c @@ -42,7 +42,8 @@ static void about_fn(void) if (ctx.repo) { size_t path_info_len = ctx.env.path_info ? strlen(ctx.env.path_info) : 0; if (!ctx.qry.path && - ctx.qry.url[strlen(ctx.qry.url) - 1] != '/' && + (!ctx.qry.url || !*ctx.qry.url || + ctx.qry.url[strlen(ctx.qry.url) - 1] != '/') && (!path_info_len || ctx.env.path_info[path_info_len - 1] != '/')) { char *currenturl = cgit_currenturl(); char *redirect = fmtalloc("%s/", currenturl); -- cgit 2.12.1