diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2011-12-15 20:47:23 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-12-15 11:35:10 -0800 |
commit | 37576c14439a4dfa43bec5a5c953fea1cc436bbf (patch) | |
tree | ab64240830bfce6d1308787f193ff8f0f77c21c0 /commit.c | |
parent | 13f8b72d8c8e24215a3dd7771592b30083f1c740 (diff) | |
download | git-37576c14439a4dfa43bec5a5c953fea1cc436bbf.tar.gz |
commit_tree(): refuse commit messages that contain NULsnd/war-on-nul-in-commit
Current implementation sees NUL as terminator. If users give a message
with NUL byte in it (e.g. editor set to save as UTF-16), the new commit
message will have NULs. However following operations (displaying or
amending a commit for example) will not keep anything after the first NUL.
Stop user right when they do this. If NUL is added by mistake, they have
their chance to fix. Otherwise, log messages will no longer be text "git
log" and friends would grok.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r-- | commit.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -855,6 +855,9 @@ int commit_tree(const struct strbuf *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); |