Subject: | Character "0" (chr 0x30) incorrectly read as "\0" (chr 0x00) |
perl v5.8.2
IO::Socket::SSL v0.95
Linux 2.6.9-22.ELsmp
# $ssl is an existing SSL socket
$buf = "0";
sysread($ssl, $buf, 1, 1);
# This SHOULD read a single character into the second position of
# $buf, and leave the first unchanged
# Instead, it replaces the first character with "\0"
The code responsible is in IO/Socket/SSL sub generic_read:
$$buffer ||= '';
Since '0' is 'false', the buffer is emptied, and later filled with "\0".
It should be replaced with
$$buffer = '' unless defined $$buffer;