commit: be more precise when searching for headers
authorRené Scharfe <l.s.r@web.de>
Sat, 25 Feb 2017 19:21:52 +0000 (20:21 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Feb 2017 19:20:17 +0000 (11:20 -0800)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit.c
index aada266f9a85e379ab2d2603b82071be4bb19ded..ee49c1ce25f57f5c2af34832ee80f6e7d4f2a0c8 100644 (file)
--- 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) ||