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/shared.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/shared.c') diff --git a/source/shared.c b/source/shared.c index a39394d..c509aa1 100644 --- a/source/shared.c +++ b/source/shared.c @@ -52,7 +52,8 @@ struct cgit_repo *cgit_add_repo(const char *url) ret = &cgit_repolist.repos[cgit_repolist.count-1]; memset(ret, 0, sizeof(struct cgit_repo)); ret->url = trim_end(url, '/'); - *strchrnul(ret->url, '\n') = '\0'; + if (ret->url) + *strchrnul(ret->url, '\n') = '\0'; ret->name = ret->url; ret->path = NULL; ret->desc = cgit_default_repo_desc; -- cgit v2.8.0