git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] for-each-ref: fix off by one read.

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 13, 2007, 00:05 UTC
Message-ID
<7vfxzb1032.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20071112053725.4f0d1940.chriscool@tuxfamily.org>
Christian Couder <chriscool@tuxfamily.org> writes:
Show 13 quoted lines
> 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.
Previous: Christian CouderNext: Christian Couder
Message 2 of 3 in “for-each-ref: fix off by one read.”
  1. for-each-ref: fix off by one read.Christian Couder, Nov 12, 2007
  2. Junio C HamanoNov 13, 2007
  3. Christian CouderNov 13, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.