List for cgit developers and users
 help / color / mirror / Atom feed
From: cgit at cryptocrack.de (Lukas Fleischer)
Subject: [PATCH v2] ui-clone.c: Fix path check
Date: Mon,  9 Feb 2015 07:25:00 +0100	[thread overview]
Message-ID: <1423463100-14347-1-git-send-email-cgit@cryptocrack.de> (raw)
In-Reply-To: <1423433647-7526-1-git-send-email-cgit@cryptocrack.de>

The starts_with() 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>
---
Using skip_prefix() might be even better here :)

 ui-clone.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ui-clone.c b/ui-clone.c
index 50569d6..1e6238d 100644
--- a/ui-clone.c
+++ b/ui-clone.c
@@ -63,8 +63,8 @@ static void send_file(char *path)
 	}
 	ctx.page.mimetype = "application/octet-stream";
 	ctx.page.filename = path;
-	if (!starts_with(ctx.repo->path, path))
-		ctx.page.filename += strlen(ctx.repo->path) + 1;
+	skip_prefix(path, ctx.repo->path, &ctx.page.filename);
+	skip_prefix(ctx.page.filename, "/", &ctx.page.filename);
 	cgit_print_http_headers();
 	html_include(path);
 }
-- 
2.3.0



  reply	other threads:[~2015-02-09  6:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-08 22:14 [PATCH] ui-clone.c: Fix starts_with() " cgit
2015-02-09  6:25 ` cgit [this message]
2015-02-09 11:01   ` [PATCH v2] ui-clone.c: Fix " 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=1423463100-14347-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).