diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
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.
Diffstat (limited to 'source/cmd.c')
-rw-r--r--source/cmd.c3
1 file changed, 2 insertions, 1 deletion
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);