commit: be more precise when searching for headers

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>

René Scharfe committed Feb 25, 2017 at 20:21 UTC 50a01cc48c9a46fe75e4a014fb7847c2f4482406
1 file changed +2 -2
commit.c
+2 -2
@@ -1354,8 +1354,8 @@ static struct commit_extra_header *read_commit_extra_header_lines(
1354 strbuf_reset(&buf);
1355 it = NULL;
1356
1357 - eof = strchr(line, ' ');
1358 - if (next <= eof)
1357 + eof = memchr(line, ' ', next - line);
1358 + if (!eof)
1359 eof = next;
1360
1361 if (standard_header_field(line, eof - line) ||