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 <[email protected]>
---
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

_______________________________________________
CGit mailing list
[email protected]
http://lists.zx2c4.com/mailman/listinfo/cgit

Reply via email to