all repos — cgit @ c699866699411346c5dba406457581013f85a873

a hyperfast web frontend for git written in c

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>
John Keeping john@keeping.me.uk
Sun, 19 Feb 2017 12:17:05 +0000
commit

c699866699411346c5dba406457581013f85a873

parent

1b4ef6783a71962f8b5da3a23f2830f0f0f55ea0

1 files changed, 1 insertions(+), 1 deletions(-)

jump to
M parsing.cparsing.c

@@ -21,6 +21,7 @@ char *c, *cmd, *p;

struct cgit_repo *repo; ctx.repo = NULL; + ctx.qry.page = NULL; if (!url || url[0] == '\0') return;

@@ -53,7 +54,6 @@ ctx.qry.path = trim_end(p + 1, '/');

} if (cmd[1]) ctx.qry.page = xstrdup(cmd + 1); - return; } }