From dc851d9eae21db8671118d798e55990e199af6af Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 13 Feb 2017 13:42:16 +0100 Subject: 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. --- src/commit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/commit.c') 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"; -- cgit v1.2.1