All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean <seanlkml@sympatico.ca>
To: git@vger.kernel.org
Subject: [PATCH] Avoid segfault when passed malformed refspec
Date: Fri, 1 Feb 2008 19:00:13 -0500	[thread overview]
Message-ID: <BAYC1-PASMTP124F1019C2D2CD7AA81CF5AE310@CEZ.ICE> (raw)


A refspec typo can cause a Null-pointer dereference and segmentation
fault.  For instance, the space before the colon in the following
example results in a segfault:

   $ git fetch ../repo  refs/heads/* :refs/heads/*
   Segmentation fault (core dumped)

To avoid the segfault, set an empty refspec destination string
if one isn't found by parsing.

Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca>
---
 remote.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/remote.c b/remote.c
index 0e00680..414c73a 100644
--- a/remote.c
+++ b/remote.c
@@ -336,6 +336,8 @@ struct refspec *parse_ref_spec(int nr_refspec, const char **refspec)
 			ep = gp;
 		}
 		rs[i].src = xstrndup(sp, ep - sp);
+		if (!rs[i].dst)
+			rs[i].dst = xstrdup("");
 	}
 	return rs;
 }
-- 
1.5.4.rc5.20.g4b806

             reply	other threads:[~2008-02-02  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-02  0:00 Sean [this message]
2008-02-02  1:03 ` [PATCH] Avoid segfault when passed malformed refspec Junio C Hamano
2008-02-02  1:26   ` Sean

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=BAYC1-PASMTP124F1019C2D2CD7AA81CF5AE310@CEZ.ICE \
    --to=seanlkml@sympatico.ca \
    --cc=git@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.