All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Christian Couder <chriscool@tuxfamily.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] for-each-ref: fix off by one read.
Date: Mon, 12 Nov 2007 16:05:37 -0800	[thread overview]
Message-ID: <7vfxzb1032.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: 20071112053725.4f0d1940.chriscool@tuxfamily.org

Christian Couder <chriscool@tuxfamily.org> writes:

> diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
> index 598d4e1..89ea37c 100644
> --- a/builtin-for-each-ref.c
> +++ b/builtin-for-each-ref.c
> @@ -306,7 +306,7 @@ static const char *find_wholine(const char *who, int wholen, const char *buf, un
>  		if (!eol)
>  			return "";
>  		eol++;
> -		if (eol[1] == '\n')
> +		if (*eol == '\n')
>  			return ""; /* end of header */
>  		buf = eol;
>  	}

Good eyes.  This would have broken if

 (1) we had a header field that consists of a single character
     and then LF.  We would have mistaken such a line as the end
     of header; or

 (2) we had a commit or a tag that consists solely of header and
     no body.  We would have read past the terminating NUL.

Thanks.

  reply	other threads:[~2007-11-13  0:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-12  4:37 [PATCH] for-each-ref: fix off by one read Christian Couder
2007-11-13  0:05 ` Junio C Hamano [this message]
2007-11-13  5:15   ` Christian Couder

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=7vfxzb1032.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=chriscool@tuxfamily.org \
    --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.