diff options
author | John Keeping | 2017-02-19 12:17:05 +0000 |
---|---|---|
committer | Jason A. Donenfeld | 2017-08-10 16:05:07 +0200 |
commit | c699866699411346c5dba406457581013f85a873 (patch) | |
tree | 1cf7f58d5884852f13f9ae6fbaffffaf0411812c /parsing.c | |
parent | 1b4ef6783a71962f8b5da3a23f2830f0f0f55ea0 (diff) | |
download | cgit-c699866699411346c5dba406457581013f85a873.tar.gz cgit-c699866699411346c5dba406457581013f85a873.tar.bz2 cgit-c699866699411346c5dba406457581013f85a873.zip |
parsing: clear query path before starting
By specifying the "url" query parameter multiple times it is possible to
end up with ctx.qry.vpath set while ctx.repo is null, which triggers an
invalid code path from cgit_print_pageheader() while printing path
crumbs, resulting in a null dereference.
The previous patch fixed this segfault, but it makes no sense for us to
clear ctx.repo while leaving ctx.qry.path set to the previous value, so
let's just clear it here so that the last "url" parameter given takes
full effect rather than partially overriding the effect of the previous
value.
Signed-off-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to 'parsing.c')
-rw-r--r-- | parsing.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -21,6 +21,7 @@ void cgit_parse_url(const char *url) | |||
21 | struct cgit_repo *repo; | 21 | struct cgit_repo *repo; |
22 | 22 | ||
23 | ctx.repo = NULL; | 23 | ctx.repo = NULL; |
24 | ctx.qry.page = NULL; | ||
24 | if (!url || url[0] == '\0') | 25 | if (!url || url[0] == '\0') |
25 | return; | 26 | return; |
26 | 27 | ||
@@ -53,7 +54,6 @@ void cgit_parse_url(const char *url) | |||
53 | } | 54 | } |
54 | if (cmd[1]) | 55 | if (cmd[1]) |
55 | ctx.qry.page = xstrdup(cmd + 1); | 56 | ctx.qry.page = xstrdup(cmd + 1); |
56 | return; | ||
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||