CC: | allan-cpan [...] oepping.com |
Subject: | Net::SSH::Perl 2.01 - available length miscalculation in Packet.pm - patch included |
Date: | Tue, 11 Oct 2016 16:03:21 -0600 |
To: | bug-Net-SSH-Perl [...] rt.cpan.org |
From: | Allan Oepping <allan [...] oepping.com> |
Version string in Packet.pm: Packet.pm,v 1.25 2008/09/24 19:21:20
turnstep Exp
In Packet.pm in fuction read_poll_ssh2 if $mac && $mac->enabled but not
$mac->etm then $block_size bytes are also read from the $incoming buffer
but the $incoming->length may not be large enough to include a full read
of $stored_mac later in the code.
I added the a return if the length including block_size is not available
(Line after the comment "RETURN IF INSUFFICIENT BUF") and that seems to
fix the issue.
if ($mac && $mac->enabled) {
if ($mac->etm) {
$p_str = $incoming->bytes(0, $aadlen + $need, '');
$macbuf = $mac->hmac(pack("N", $seqnr) . $p_str);
# remove packet length bytes
substr($p_str,0,$aadlen,'');
} else {
#RETURN IF INSUFFICIENT BUF
return if $incoming->length < $aadlen + $need + $authlen
+ $maclen + $block_size;
# not etm mac, append bytes already decrypted above
$buffer->append( $incoming->bytes(0, $block_size, '') );
$p_str = $incoming->bytes(0, $need, '');
}
Unified diff/patch attached.
Thanks,
Allan Oepping
Message body is not shown because sender requested not to inline it.