Subject: | Error downloading file when block_size is lower than 2048 bytes |
Date: | Mon, 9 Dec 2013 19:21:54 +0100 |
To: | bug-Net-SFTP-Foreign [...] rt.cpan.org |
From: | Danilo Luna <danilo.luna [...] gmail.com> |
At Net::SFTP::Foreign::get::1706 (version 1.77) you will find:
if ($len < $block_size) {
$block_size = $len < 2048 ? *2048 : $len*;
$askoff = $loff;
}
You cannot set the $block_size to 2048 if $len < 2048 otherwise the $roff
ans $loff variables will be out of sync and the following will be executed
on the next run.
if ($roff != $loff or !$len) {
$sftp->_set_error(SFTP_ERR_REMOTE_BLOCK_TOO_SMALL,
"remote packet received is too small" );
last;
}
To correct the bug, invert the result of the ternary statement:
if ($len < $block_size) {
###### bug #################
# if $len is lower than 2048 mess up with the offsets
############################
$block_size = $len < 2048 ? *$len : 2048*;
$askoff = $loff;
}
Kind Regards
Danilo