mailsplit and mailinfo: gracefully handle NUL characters
The function fgets() has a big problem with NUL characters: it reads them, but nobody will know if the NUL comes from the file stream, or was appended at the end of the line. So implement a custom read_line_with_nul() function. Noticed by Tommy Thorn. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
182fb4df91
commit
cce8d6fdb4
@ -25,4 +25,13 @@ do
|
||||
diff ../t5100/info$mail info$mail"
|
||||
done
|
||||
|
||||
test_expect_success 'respect NULs' '
|
||||
|
||||
git mailsplit -d3 -o. ../t5100/nul &&
|
||||
cmp ../t5100/nul 001 &&
|
||||
(cat 001 | git mailinfo msg patch) &&
|
||||
test 4 = $(wc -l < patch)
|
||||
|
||||
'
|
||||
|
||||
test_done
|
||||
|
BIN
t/t5100/nul
Normal file
BIN
t/t5100/nul
Normal file
Binary file not shown.
Reference in New Issue
Block a user