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

[PATCH 1/2] commit: be more precise when searching for headers

From
René Scharfe <l.s.r@web.de>
Date
Feb 25, 2017, 19:21 UTC
Message-ID
<23989e76-24ba-90a4-91a9-9f66bfccb7c9@web.de>

Search for a space character only within the current line in read_commit_extra_header_lines() instead of searching in the whole buffer (and possibly beyond, if it's not NUL-terminated) and then discarding any results after the end of the current line.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 commit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/commit.c b/commit.c
index 2cf85158b4..173c6d3818 100644
--- a/commit.c
+++ b/commit.c
@@ -1354,8 +1354,8 @@ static struct commit_extra_header *read_commit_extra_header_lines(
 		strbuf_reset(&buf);
 		it = NULL;
 
-		eof = strchr(line, ' ');
-		if (next <= eof)
+		eof = memchr(line, ' ', next - line);
+		if (!eof)
 			eof = next;
 
 		if (standard_header_field(line, eof - line) ||
-- 
2.12.0
Next: René Scharfe
Message 1 of 9 in “commit: be more precise when searching for headers”
  1. 1/2 commit: be more precise when searching for headersRené Scharfe, Feb 25, 2017
  2. 2/2 commit: don't check for space twice when looking for headerRené Scharfe, Feb 25, 2017
  3. Jeff KingFeb 25, 2017
  4. René ScharfeFeb 25, 2017
  5. Jeff KingFeb 25, 2017
  6. Jakub NarębskiFeb 27, 2017
  7. René ScharfeFeb 27, 2017
  8. Jeff KingFeb 25, 2017
  9. Junio C HamanoFeb 27, 2017

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.