diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index a148152d..176c972a 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -1568,6 +1568,13 @@ class SFTP extends SSH2 } $i++; + + if ($i >= NET_SFTP_QUEUE_SIZE) { + if (!$this->read_put_responses($i)) { + return false; + } + $i = 0; + } } } @@ -1577,8 +1584,11 @@ class SFTP extends SSH2 $i++; - if (!$this->read_put_responses($i)) { - return false; + if ($i >= NET_SFTP_QUEUE_SIZE) { + if (!$this->read_put_responses($i)) { + return false; + } + $i = 0; } return true; @@ -1940,7 +1950,7 @@ class SFTP extends SSH2 $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, $i)) { + if (!$this->send_sftp_packet(NET_SFTP_WRITE, $packet)) { if ($mode & self::SOURCE_LOCAL_FILE) { fclose($fp); } @@ -1952,6 +1962,14 @@ class SFTP extends SSH2 } $i++; + + if ($i == NET_SFTP_QUEUE_SIZE) { + if (!$this->read_put_responses($i)) { + $i = 0; + break; + } + $i = 0; + } } if (!$this->read_put_responses($i)) { @@ -2236,7 +2254,10 @@ class SFTP extends SSH2 return false; } - return $this->delete_recursive($path); + $i = 0; + $result = $this->delete_recursive($path, $i); + $this->read_put_responses($i); + return $result; } $this->remove_from_stat_cache($path); @@ -2254,8 +2275,11 @@ class SFTP extends SSH2 * @return bool * @access private */ - private function delete_recursive($path) + private function delete_recursive($path, &$i) { + if (!$this->read_put_responses($i)) { + return false; + } $i = 0; $entries = $this->readlist($path, true); @@ -2283,6 +2307,13 @@ class SFTP extends SSH2 $this->remove_from_stat_cache($temp); $i++; + + if ($i >= NET_SFTP_QUEUE_SIZE) { + if (!$this->read_put_responses($i)) { + return false; + } + $i = 0; + } } } @@ -2293,8 +2324,11 @@ class SFTP extends SSH2 $i++; - if (!$this->read_put_responses($i)) { - return false; + if ($i >= NET_SFTP_QUEUE_SIZE) { + if (!$this->read_put_responses($i)) { + return false; + } + $i = 0; } return true;