mirror of
https://github.com/danog/phpseclib.git
synced 2024-11-27 12:55:58 +01:00
fixed sending stream resulting in a zero byte file
This commit is contained in:
parent
b6801c837c
commit
6c8affcf11
@ -1933,7 +1933,7 @@ class Net_SFTP extends Net_SSH2
|
||||
// make the SFTP packet be exactly 4096 bytes by including the bytes in the NET_SFTP_WRITE packets "header"
|
||||
$sftp_packet_size-= strlen($handle) + 25;
|
||||
$i = 0;
|
||||
while ($dataCallback || ($sent < $size)) {
|
||||
while ($dataCallback || ($size === 0 || $sent < $size)) {
|
||||
if ($dataCallback) {
|
||||
$temp = call_user_func($dataCallback, $sftp_packet_size);
|
||||
if (is_null($temp)) {
|
||||
@ -1941,7 +1941,11 @@ class Net_SFTP extends Net_SSH2
|
||||
}
|
||||
} else {
|
||||
$temp = isset($fp) ? fread($fp, $sftp_packet_size) : substr($data, $sent, $sftp_packet_size);
|
||||
if ($temp === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$subtemp = $offset + $sent;
|
||||
$packet = pack('Na*N3a*', strlen($handle), $handle, $subtemp / 4294967296, $subtemp, strlen($temp), $temp);
|
||||
if (!$this->_send_sftp_packet(NET_SFTP_WRITE, $packet)) {
|
||||
|
Loading…
Reference in New Issue
Block a user