mirror of
https://github.com/git/git.git
synced 2024-11-23 18:05:29 +08:00
mailinfo: disallow NUL character in mail's header
Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
2a2ff60396
commit
3919997447
@ -1138,6 +1138,11 @@ static void handle_info(struct mailinfo *mi)
|
||||
else
|
||||
continue;
|
||||
|
||||
if (memchr(hdr->buf, '\0', hdr->len)) {
|
||||
error("a NUL byte in '%s' is not allowed.", header[i]);
|
||||
mi->input_error = -1;
|
||||
}
|
||||
|
||||
if (!strcmp(header[i], "Subject")) {
|
||||
if (!mi->keep_subject) {
|
||||
cleanup_subject(mi, hdr);
|
||||
|
@ -70,10 +70,13 @@ test_expect_success "NUL in commit message's body" '
|
||||
grep "a NUL byte in commit log message not allowed" err
|
||||
'
|
||||
|
||||
test_expect_failure "NUL in commit message's header" "
|
||||
test_expect_success "NUL in commit message's header" "
|
||||
test_when_finished 'git am --abort' &&
|
||||
make_mbox_with_nul subject >subject.patch &&
|
||||
test_must_fail git am subject.patch
|
||||
test_must_fail git mailinfo msg patch <subject.patch 2>err &&
|
||||
grep \"a NUL byte in 'Subject' is not allowed\" err &&
|
||||
test_must_fail git am subject.patch 2>err &&
|
||||
grep \"a NUL byte in 'Subject' is not allowed\" err
|
||||
"
|
||||
|
||||
test_done
|
||||
|
Loading…
Reference in New Issue
Block a user