From mboxrd@z Thu Jan 1 00:00:00 1970 From: cgit at cryptocrack.de (Lukas Fleischer) Date: Sun, 8 Feb 2015 23:14:07 +0100 Subject: [PATCH] ui-clone.c: Fix starts_with() path check Message-ID: <1423433647-7526-1-git-send-email-cgit@cryptocrack.de> The check was broken in two ways: For one thing, the parameters were passed in the wrong order, for another thing, starts_with() returns 1 if the string starts with the prefix (not 0). Note that this bug existed since commit 02a545e (Add support for cloning over http, 2008-08-06) but only pops in in corner cases. Signed-off-by: Lukas Fleischer --- Jason, I stumbled across this when trying to reproduce the bug you reported earlier. Not sure if it is related but it's clearly a bug. One reason why we haven't seen this occur earlier is that it only manifests in a few rare cases (no packed refs, special requirements to repository paths). ui-clone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-clone.c b/ui-clone.c index 50569d6..9b93459 100644 --- a/ui-clone.c +++ b/ui-clone.c @@ -63,7 +63,7 @@ static void send_file(char *path) } ctx.page.mimetype = "application/octet-stream"; ctx.page.filename = path; - if (!starts_with(ctx.repo->path, path)) + if (starts_with(path, ctx.repo->path)) ctx.page.filename += strlen(ctx.repo->path) + 1; cgit_print_http_headers(); html_include(path); -- 2.3.0