List for cgit developers and users
 help / color / mirror / Atom feed
From: john at keeping.me.uk (John Keeping)
Subject: [PATCH] ui-blob: don't segfault  when no path is given
Date: Sun,  7 Apr 2013 15:06:23 +0100	[thread overview]
Message-ID: <3158d425f06b02bff2a6506af9307d8ddc16f0a9.1365343407.git.john@keeping.me.uk> (raw)

It it possible to inspect blobs by specifying only the SHA-1, and CGit
provides links to do so, for example if a tag points directly at a blob.
In this case the path_items structure is never used, but creating it
still causes strlen to be run on a null pointer.  Fix this.

This error was introduced by commit c1633c6 (Update git to v1.7.6.5 -
2013-03-02).

Signed-off-by: John Keeping <john at keeping.me.uk>
---
You can see this by inspecting the "larsh-public-key" tag in cgit.git.

I noticed this because I was running under Clang's address sanitizer,
which also meant I had compiled with -O1, I wonder if this could be
optimized away at higher optimization levels.

 ui-blob.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui-blob.c b/ui-blob.c
index c59fbcb..7aec0b1 100644
--- a/ui-blob.c
+++ b/ui-blob.c
@@ -80,7 +80,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head)
 	struct commit *commit;
 	struct pathspec_item path_items = {
 		.match = path,
-		.len = strlen(path)
+		.len = path ? strlen(path) : 0
 	};
 	struct pathspec paths = {
 		.nr = 1,
-- 
1.8.2.692.g17a9715





             reply	other threads:[~2013-04-07 14:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-07 14:06 john [this message]
2013-04-07 14:08 ` 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=3158d425f06b02bff2a6506af9307d8ddc16f0a9.1365343407.git.john@keeping.me.uk \
    --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).