git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Carl Worth <cworth@cworth.org>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: [PATCH] Prevent git-upload-pack segfault if object cannot be found
Date: Fri, 17 Feb 2006 16:14:52 -0800	[thread overview]
Message-ID: <87hd6x34lf.wl%cworth@cworth.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1469 bytes --]

Signed-off-by: Carl Worth <cworth@cworth.org>

---

It's probably a just-don't-do-that situation, but I did-it by moving a
directory that had already been cached in objects/info/alternates by
clone -l -s. Here's a fix for the segfault that that turned up.

Probably trivial enough to not bother the list with, but I'm still
learning about formatting patches and mails and things, so I'm open to
any feedback if I'm getting anything wrong.

 sha1_file.c   |    4 +++-
 upload-pack.c |    3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/sha1_file.c b/sha1_file.c
index 64cf245..1d799f7 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -551,8 +551,10 @@ static void prepare_packed_git_one(char 
 	sprintf(path, "%s/pack", objdir);
 	len = strlen(path);
 	dir = opendir(path);
-	if (!dir)
+	if (!dir) {
+		fprintf(stderr, "unable to open object pack directory: %s: %s\n", path, strerror(errno));
 		return;
+	}
 	path[len++] = '/';
 	while ((de = readdir(dir)) != NULL) {
 		int namelen = strlen(de->d_name);
diff --git a/upload-pack.c b/upload-pack.c
index d198055..3606529 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -216,6 +216,9 @@ static int send_ref(const char *refname,
 	static char *capabilities = "multi_ack";
 	struct object *o = parse_object(sha1);
 
+	if (!o)
+		die("git-upload-pack: cannot find object %s:", sha1_to_hex(sha1));
+
 	if (capabilities)
 		packet_write(1, "%s %s%c%s\n", sha1_to_hex(sha1), refname,
 			0, capabilities);

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

             reply	other threads:[~2006-02-18  0:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-18  0:14 Carl Worth [this message]
2006-02-18  6:50 ` [PATCH] Prevent git-upload-pack segfault if object cannot be found Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2006-02-22 18:17 Andrew Vasquez
2006-02-22 18:26 ` Junio C Hamano
2006-02-22 18:44 ` Carl Worth
2006-02-22 18:50   ` Junio C Hamano
2006-02-22 19:11   ` Junio C Hamano
2006-02-22 19:16     ` Carl Worth
2006-02-23  0:34     ` Jonas Fonseca

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=87hd6x34lf.wl%cworth@cworth.org \
    --to=cworth@cworth.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /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).