From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carl Worth Subject: [PATCH] Prevent git-upload-pack segfault if object cannot be found Date: Fri, 17 Feb 2006 16:14:52 -0800 Message-ID: <87hd6x34lf.wl%cworth@cworth.org> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: multipart/signed; boundary="pgp-sign-Multipart_Fri_Feb_17_16:14:51_2006-1"; micalg=pgp-sha1; protocol="application/pgp-signature" Content-Transfer-Encoding: 7bit Cc: git@vger.kernel.org X-From: git-owner@vger.kernel.org Sat Feb 18 01:16:09 2006 Return-path: Envelope-to: gcvg-git@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FAFlf-0008Uv-BB for gcvg-git@gmane.org; Sat, 18 Feb 2006 01:16:07 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751731AbWBRAPv (ORCPT ); Fri, 17 Feb 2006 19:15:51 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751806AbWBRAPv (ORCPT ); Fri, 17 Feb 2006 19:15:51 -0500 Received: from theworths.org ([217.160.253.102]:61147 "EHLO theworths.org") by vger.kernel.org with ESMTP id S1751731AbWBRAPu (ORCPT ); Fri, 17 Feb 2006 19:15:50 -0500 Received: (qmail 26356 invoked from network); 17 Feb 2006 19:15:49 -0500 Received: from localhost (HELO raht.cworth.org) (127.0.0.1) by localhost with SMTP; 17 Feb 2006 19:15:49 -0500 To: Junio C Hamano User-Agent: Wanderlust/2.14.0 (Africa) Emacs/21.4 Mule/5.0 (SAKAKI) Sender: git-owner@vger.kernel.org Precedence: bulk X-Mailing-List: git@vger.kernel.org Archived-At: --pgp-sign-Multipart_Fri_Feb_17_16:14:51_2006-1 Content-Type: text/plain; charset=US-ASCII Signed-off-by: Carl Worth --- 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); --pgp-sign-Multipart_Fri_Feb_17_16:14:51_2006-1 Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) iD8DBQBD9mb86JDdNq8qSWgRAt7OAJ94L5wPxbB50wgAmS+f4/m38XBKeQCeJuUl gt+4mryPM1AjGs649Prq2/I= =8x6Q -----END PGP SIGNATURE----- --pgp-sign-Multipart_Fri_Feb_17_16:14:51_2006-1--