diff options
author | Đoàn Trần Công Danh <congdanhqx@gmail.com> | 2020-04-21 06:54:35 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-04-22 14:01:02 -0700 |
commit | 2a2ff6039606b93ad08d8d377804ddcd0bc41312 (patch) | |
tree | 1e44eb3de7c5ca3631ae16da67e7c2c65406e49c /t/t1307-config-blob.sh | |
parent | t4254: merge 2 steps of a single test (diff) | |
download | tgif-2a2ff6039606b93ad08d8d377804ddcd0bc41312.tar.xz |
mailinfo.c: avoid strlen on strings that can contains NUL
We're passing buffer from strbuf to reencode_string,
which will call strlen(3) on that buffer,
and discard the length of newly created buffer.
Then, we compute the length of the return buffer to attach to strbuf.
During this process, we introduce a discrimination between mail
originally written in utf-8 and other encoding.
* if the email was written in utf-8, we leave it as is. If there is
a NUL character in that line, we complains loudly:
error: a NUL byte in commit log message not allowed.
* if the email was written in other encoding, we truncate the data as
the NUL character in that line, then we used the truncated line for
the metadata.
We can do better by reusing all the available information,
and call the underlying lower level function that will be called
indirectly by reencode_string. By doing this, we will also postpone
the NUL character processing to the commit step, which will
complains about the faulty metadata.
Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1307-config-blob.sh')
0 files changed, 0 insertions, 0 deletions