summaryrefslogtreecommitdiff
path: root/pretty.c
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2007-12-20 12:20:15 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-12-27 01:52:32 (GMT)
commit7ed0988adc0a3cb3f103c105af387e3ac48eea61 (patch)
treef917862a230f7c19a470e6988e332129f3bd0fcd /pretty.c
parentcc216827936e40bc2e8886623fd44f55e0674932 (diff)
downloadgit-7ed0988adc0a3cb3f103c105af387e3ac48eea61.zip
git-7ed0988adc0a3cb3f103c105af387e3ac48eea61.tar.gz
git-7ed0988adc0a3cb3f103c105af387e3ac48eea61.tar.bz2
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>
Diffstat (limited to 'pretty.c')
-rw-r--r--pretty.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/pretty.c b/pretty.c
index 9db75b4..5b1078b 100644
--- a/pretty.c
+++ b/pretty.c
@@ -412,7 +412,7 @@ static void parse_commit_header(struct format_commit_context *context)
if (i == eol) {
state++;
/* strip empty lines */
- while (msg[eol + 1] == '\n')
+ while (msg[eol] == '\n' && msg[eol + 1] == '\n')
eol++;
} else if (!prefixcmp(msg + i, "author ")) {
context->author.off = i + 7;
@@ -425,6 +425,8 @@ static void parse_commit_header(struct format_commit_context *context)
context->encoding.len = eol - i - 9;
}
i = eol;
+ if (!msg[i])
+ break;
}
context->body_off = i;
context->commit_header_parsed = 1;