diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 1e6fba9f..8c458b1c 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -269,6 +269,21 @@ class SFTP extends SSH2 */ var $preserveTime = false; + /** + * Arbitrary Length Packets Flag + * + * Determines whether or not packets of any length should be allowed, + * in cases where the server chooses the packet length (such as + * directory listings). By default, packets are only allowed to be + * 256 * 1024 bytes (SFTP_MAX_MSG_LENGTH from OpenSSH's sftp-common.h) + * + * @see self::enableArbitraryLengthPackets() + * @see self::_get_sftp_packet() + * @var bool + * @access private + */ + var $allow_arbitrary_length_packets = false; + /** * Was the last packet due to the channels being closed or not? * @@ -644,6 +659,16 @@ class SFTP extends SSH2 $this->canonicalize_paths = true; } + /** + * Enable arbitrary length packets + * + * @access public + */ + function enableArbitraryLengthPackets() + { + $this->allow_arbitrary_length_packets = true; + } + /** * Enable path canonicalization * @@ -3126,7 +3151,7 @@ class SFTP extends SSH2 // 256 * 1024 is what SFTP_MAX_MSG_LENGTH is set to in OpenSSH's sftp-common.h - if (!$this->use_request_id && $tempLength > 256 * 1024) { + if (!$this->allow_arbitrary_length_packets &&!$this->use_request_id && $tempLength > 256 * 1024) { user_error('Invalid SFTP packet size'); return false; }