diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce 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')
| -rw-r--r-- | source/cmd.c | 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rw-r--r-- | source/shared.c | 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 files changed, 4 insertions, 2 deletions
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); 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; |
