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

Re: Serious bug with pretty format strings & empty bodies?

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Dec 20, 2007, 12:20 UTC
Message-ID
<476A5DFF.40803@lsrfire.ath.cx>
In-Reply-To
<57518fd10712200244o656c7f44j426cc71c89515de3@mail.gmail.com>
Jonathan del Strother schrieb:
> On Dec 19, 2007 11:23 PM, René Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:
>> Just a shot in the dark: does this patch on top of master make a difference?
> No luck with that, I'm afraid.
And how is this one?

The first chunk is the same as in the last try -- it guards against commit messages ending with a NUL without a prior \n _and_ being followed by a \n (in memory which shouldn't be accessed by us at all as it doesn't belong to the commit message). I guess that's quite rare.

The second chunk keeps the body offset from being incremented by the for loop if we've already found a terminating NUL.

diff --git a/pretty.c b/pretty.c
index 9db75b4..5b1078b 100644
--- a/pretty.c
+++ b/pretty.c
@@ -412,7 +412,7 @@ static void parse_commit_header(struct format_commit_context *context)
 		if (i == eol) {
 			state++;
 			/* strip empty lines */
-			while (msg[eol + 1] == '\n')
+			while (msg[eol] == '\n' && msg[eol + 1] == '\n')
 				eol++;
 		} else if (!prefixcmp(msg + i, "author ")) {
 			context->author.off = i + 7;
@@ -425,6 +425,8 @@ static void parse_commit_header(struct format_commit_context *context)
 			context->encoding.len = eol - i - 9;
 		}
 		i = eol;
+		if (!msg[i])
+			break;
 	}
 	context->body_off = i;
 	context->commit_header_parsed = 1;
Previous: Jonathan del StrotherNext: Johannes Schindelin
Message 9 of 16 in “Serious bug with pretty format strings & empty bodies?”
  1. Jonathan del StrotherDec 19, 2007
  2. René ScharfeDec 19, 2007
  3. Jonathan del StrotherDec 20, 2007
  4. Jonathan del StrotherDec 20, 2007
  5. Alex RiesenDec 19, 2007
  6. Jonathan del StrotherDec 19, 2007
  7. René ScharfeDec 19, 2007
  8. Jonathan del StrotherDec 20, 2007
  9. René ScharfeDec 20, 2007
  10. Johannes SchindelinDec 20, 2007
  11. Jonathan del StrotherDec 20, 2007
  12. Jonathan del StrotherDec 21, 2007
  13. Junio C HamanoDec 22, 2007
  14. Jonathan del StrotherDec 22, 2007
  15. Jonathan del StrotherDec 20, 2007
  16. Johannes SchindelinDec 20, 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.