about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Keeping <john@keeping.me.uk>2017-02-19 12:17:05 +0000
committerJason A. Donenfeld <Jason@zx2c4.com>2017-08-10 16:05:07 +0200
commitc699866699411346c5dba406457581013f85a873 (patch)
tree1cf7f58d5884852f13f9ae6fbaffffaf0411812c
parentui-shared: don't print path crumbs without a repo (diff)
downloadcgit-pink-c699866699411346c5dba406457581013f85a873.tar.gz
cgit-pink-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>
-rw-r--r--parsing.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/parsing.c b/parsing.c
index 9dacb16..b8d7f10 100644
--- a/parsing.c
+++ b/parsing.c
@@ -21,6 +21,7 @@ void cgit_parse_url(const char *url)
 	struct cgit_repo *repo;
 
 	ctx.repo = NULL;
+	ctx.qry.page = NULL;
 	if (!url || url[0] == '\0')
 		return;
 
@@ -53,7 +54,6 @@ void cgit_parse_url(const char *url)
 		}
 		if (cmd[1])
 			ctx.qry.page = xstrdup(cmd + 1);
-		return;
 	}
 }