diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2013-01-20 04:20:09 +0100 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2013-01-20 04:20:09 +0100 |
commit | d47c6aabfe8301577a6e4067aacd9ed6782e4035 (patch) | |
tree | 979c827cb4e575a1bb271d941ee30f3e33476596 /src/commit.c | |
parent | 7a2cf780d13106cfd90ea33431b6444880c05123 (diff) | |
download | libgit2-d47c6aabfe8301577a6e4067aacd9ed6782e4035.tar.gz |
commit: don't include the LF in the header field value
When the encoding header changed to be treated as an additional
header, the EOL pointer started to point to the byte after the LF,
making the git__strndup call copy the LF into the value.
Increase the EOL pointer value after copying the data to keep the rest
of the semantics but avoid copying LF.
Diffstat (limited to 'src/commit.c')
-rw-r--r-- | src/commit.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/commit.c b/src/commit.c index 9449224ef..2714f1acc 100644 --- a/src/commit.c +++ b/src/commit.c @@ -174,8 +174,6 @@ int git_commit__parse_buffer(git_commit *commit, const void *data, size_t len) const char *eoln = buffer; while (eoln < buffer_end && *eoln != '\n') ++eoln; - if (eoln < buffer_end && *eoln == '\n') - ++eoln; if (git__prefixcmp(buffer, "encoding ") == 0) { buffer += strlen("encoding "); @@ -184,6 +182,9 @@ int git_commit__parse_buffer(git_commit *commit, const void *data, size_t len) GITERR_CHECK_ALLOC(commit->message_encoding); } + if (eoln < buffer_end && *eoln == '\n') + ++eoln; + buffer = eoln; } |