Make "--pretty=format" parser a bit more careful.
When a commit message that does not have a terminating LF is read in and the memory that was allocated to read it happens to have a LF immediately after that, the code was not careful and went past the terminating NUL. Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Dec 20, 2007 at 13:20 UTC
7ed0988adc0a3cb3f103c105af387e3ac48eea61
1 file changed
+3
-1
pretty.c
+3
-1
@@ -412,7 +412,7 @@ static void parse_commit_header(struct format_commit_context *context)
412
if (i == eol) {
413
state++;
414
/* strip empty lines */
415
- while (msg[eol + 1] == '\n')
415
+ while (msg[eol] == '\n' && msg[eol + 1] == '\n')
416
eol++;
417
} else if (!prefixcmp(msg + i, "author ")) {
418
context->author.off = i + 7;
@@ -425,6 +425,8 @@ static void parse_commit_header(struct format_commit_context *context)
425
context->encoding.len = eol - i - 9;
426
}
427
i = eol;
428
+ if (!msg[i])
429
+ break;
430
}
431
context->body_off = i;
432
context->commit_header_parsed = 1;