Merge pull request #237 from terrafrost/sftp-get-size-fix

SFTP: make get() return correctly sized strings

* terrafrost/sftp-get-size-fix:
  SFTP: make get() return correctly sized strings
This commit is contained in:
Andreas Fischer 2013-12-28 13:41:03 +01:00
commit b82478b48f

View File

@ -1685,6 +1685,7 @@ class Net_SFTP extends Net_SSH2
$content = '';
}
$start = $offset;
$size = $this->max_sftp_packet < $length || $length < 0 ? $this->max_sftp_packet : $length;
while (true) {
$packet = pack('Na*N3', strlen($handle), $handle, $offset / 4294967296, $offset, $size);
@ -1718,12 +1719,12 @@ class Net_SFTP extends Net_SSH2
return false;
}
if ($length > 0 && $length <= $offset - $size) {
if ($length > 0 && $length <= $offset - $start) {
break;
}
}
if ($length > 0 && $length <= $offset - $size) {
if ($length > 0 && $length <= $offset - $start) {
if ($local_file === false) {
$content = substr($content, 0, $length);
} else {