From caf5a8d7e4409d5e3c5879b31c55c54bd51e6024 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Wed, 15 Jul 2026 12:18:14 -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 v2.8.0