X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=commit.c;h=80e61b4cf551a05b06f5944018265868767515bf;hb=37576c14439a4dfa43bec5a5c953fea1cc436bbf;hp=73b7e00292ba2de33fa43b5f028fd807a460af34;hpb=b1b7cedcfe351870d4c56f664695a25f8651d5b3;p=git.git diff --git a/commit.c b/commit.c index 73b7e0029..80e61b4cf 100644 --- a/commit.c +++ b/commit.c @@ -845,7 +845,7 @@ static const char commit_utf8_warn[] = "You may want to amend it after fixing the message, or set the config\n" "variable i18n.commitencoding to the encoding your project uses.\n"; -int commit_tree(const char *msg, unsigned char *tree, +int commit_tree(const struct strbuf *msg, unsigned char *tree, struct commit_list *parents, unsigned char *ret, const char *author) { @@ -855,6 +855,9 @@ int commit_tree(const char *msg, unsigned char *tree, assert_sha1_type(tree, OBJ_TREE); + if (memchr(msg->buf, '\0', msg->len)) + return error("a NUL byte in commit log message not allowed."); + /* Not having i18n.commitencoding is the same as having utf-8 */ encoding_is_utf8 = is_encoding_utf8(git_commit_encoding); @@ -884,7 +887,7 @@ int commit_tree(const char *msg, unsigned char *tree, strbuf_addch(&buffer, '\n'); /* And add the comment */ - strbuf_addstr(&buffer, msg); + strbuf_addbuf(&buffer, msg); /* And check the encoding */ if (encoding_is_utf8 && !is_utf8(buffer.buf))