From: cgit at cryptocrack.de (Lukas Fleischer)
Subject: [PATCH] ui-clone.c: Fix starts_with() path check
Date: Sun, 8 Feb 2015 23:14:07 +0100 [thread overview]
Message-ID: <1423433647-7526-1-git-send-email-cgit@cryptocrack.de> (raw)
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 <cgit at cryptocrack.de>
---
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
next reply other threads:[~2015-02-08 22:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-08 22:14 cgit [this message]
2015-02-09 6:25 ` [PATCH v2] ui-clone.c: Fix " cgit
2015-02-09 11:01 ` Jason
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1423433647-7526-1-git-send-email-cgit@cryptocrack.de \
--to=cgit@lists.zx2c4.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).