Commit 94fce582f0023c3136d342e48ce9a43431080414

Edward Thomson 2018-11-21T10:27:59

Merge pull request #4894 from pks-t/pks/commit-author-oob commit: fix out-of-bound reads when parsing truncated author fields

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/commit.c b/src/commit.c
index bda5a8b..a26368c 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -420,7 +420,7 @@ int git_commit__parse_raw(void *_commit, const char *data, size_t size)
 		return -1;
 
 	/* Some tools create multiple author fields, ignore the extra ones */
-	while ((size_t)(buffer_end - buffer) >= strlen("author ") && !git__prefixcmp(buffer, "author ")) {
+	while (!git__prefixncmp(buffer, buffer_end - buffer, "author ")) {
 		if (git_signature__parse(&dummy_sig, &buffer, buffer_end, "author ", '\n') < 0)
 			return -1;