Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Fraser Tweedale <frase@frase.id.au>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] push: fix segfault when HEAD points nowhere
Date: Thu, 31 Jan 2013 08:06:19 -0800	[thread overview]
Message-ID: <7vlib9ibgk.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1359634971-79036-1-git-send-email-frase@frase.id.au> (Fraser Tweedale's message of "Thu, 31 Jan 2013 22:22:51 +1000")

Fraser Tweedale <frase@frase.id.au> writes:

> When reporting the outcome of a push, a segfault occurs if HEAD does
> not point somewhere.  Check that HEAD points somewhere before trying
> to strcmp it.
>
> Signed-off-by: Fraser Tweedale <frase@frase.id.au>
> ---
>  transport.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/transport.c b/transport.c
> index 9932f40..b9306ef 100644
> --- a/transport.c
> +++ b/transport.c
> @@ -741,7 +741,7 @@ void transport_print_push_status(const char *dest, struct ref *refs,
>  			n += print_one_push_status(ref, dest, n, porcelain);
>  		if (ref->status == REF_STATUS_REJECT_NONFASTFORWARD &&
>  		    *nonfastforward != NON_FF_HEAD) {
> -			if (!strcmp(head, ref->name))
> +			if (head != NULL && !strcmp(head, ref->name))
>  				*nonfastforward = NON_FF_HEAD;
>  			else
>  				*nonfastforward = NON_FF_OTHER;

Wow.

This is a bug that is hard to trigger by just using the software
(you have to be doubly insane to be on an unborn branch and pushing
out a branch that is not the one you are currently on) and one has
to look at the code to hunt for it.

The fix looks correct.  Thank you very much for spotting.

      reply	other threads:[~2013-01-31 16:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-31 12:22 [PATCH] push: fix segfault when HEAD points nowhere Fraser Tweedale
2013-01-31 16:06 ` Junio C Hamano [this message]

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=7vlib9ibgk.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=frase@frase.id.au \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox