diff options
author | Patrick Steinhardt <ps@pks.im> | 2017-02-13 13:42:16 +0100 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2017-02-13 13:50:52 +0100 |
commit | dc851d9eae21db8671118d798e55990e199af6af (patch) | |
tree | 686147480fd6cac839d548c5427ab09cc520da4e /src/commit.c | |
parent | cdb2c2a0bf9428ea188959f332e9f541a2fb2af1 (diff) | |
download | libgit2-dc851d9eae21db8671118d798e55990e199af6af.tar.gz |
commit: clear user-provided buffers
The functions `git_commit_header_field` and
`git_commit_extract_signature` both receive buffers used to hand back
the results to the user. While these functions called `git_buf_sanitize`
on these buffers, this is not the right thing to do, as it will simply
initialize or zero-terminate passed buffers. As we want to overwrite
contents, we instead have to call `git_buf_clear` to completely reset
them.
Diffstat (limited to 'src/commit.c')
-rw-r--r-- | src/commit.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/commit.c b/src/commit.c index 87ab2ab60..89a4db115 100644 --- a/src/commit.c +++ b/src/commit.c @@ -642,7 +642,7 @@ int git_commit_header_field(git_buf *out, const git_commit *commit, const char * { const char *eol, *buf = commit->raw_header; - git_buf_sanitize(out); + git_buf_clear(out); while ((eol = strchr(buf, '\n'))) { /* We can skip continuations here */ @@ -706,8 +706,8 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r const char *h, *eol; int error; - git_buf_sanitize(signature); - git_buf_sanitize(signed_data); + git_buf_clear(signature); + git_buf_clear(signed_data); if (!field) field = "gpgsig"; |