From 85205bf6d5ea62249ed31585e31c39ed16747714 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Tue, 14 Jun 2022 05:30:24 -0500 Subject: [PATCH 1/3] SSH2: set channel closure flag elsewhere as well --- phpseclib/Net/SFTP.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 4d5c4200..f6cffeac 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -3673,6 +3673,9 @@ class Net_SFTP extends Net_SSH2 while ($tempLength > 0) { $temp = $this->_get_channel_packet(NET_SFTP_CHANNEL, true); if (is_bool($temp)) { + if ($temp && $this->channel_status[NET_SFTP_CHANNEL] === NET_SSH2_MSG_CHANNEL_CLOSE) { + $this->channel_close = true; + } $this->packet_type = false; $this->packet_buffer = ''; return false; From 413dcb6082e0b24a435f5614974c912c5dfbb530 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Tue, 14 Jun 2022 05:32:38 -0500 Subject: [PATCH 2/3] SFTP: update for 2.0 code --- phpseclib/Net/SFTP.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index b738056e..72ffd198 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -3618,7 +3618,7 @@ class SFTP extends SSH2 while ($tempLength > 0) { $temp = $this->_get_channel_packet(self::CHANNEL, true); if (is_bool($temp)) { - if ($temp && $this->channel_status[NET_SFTP_CHANNEL] === NET_SSH2_MSG_CHANNEL_CLOSE) { + if ($temp && $this->channel_status[self::CHANNEL] === NET_SSH2_MSG_CHANNEL_CLOSE) { $this->channel_close = true; } $this->packet_type = false; From 623bb39f1cfd53a48cd4d59246ef6990e1a81f99 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Tue, 14 Jun 2022 05:43:31 -0500 Subject: [PATCH 3/3] SFTP: update for 3.0 branch in 1.0 / 2.0 _get_channel_packet could return false even when the channel status was NET_SSH2_MSG_CHANNEL_DATA. in 3.0 it can't. where 1.0 / 2.0 returned false 3.0 now throws exceptions --- phpseclib/Net/SFTP.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index aa58af8f..fc1576cd 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -3280,8 +3280,8 @@ class SFTP extends SSH2 // SFTP packet type and data payload while ($tempLength > 0) { $temp = $this->get_channel_packet(self::CHANNEL, true); - if (is_bool($temp)) { - if ($temp && $this->channel_status[self::CHANNEL] === NET_SSH2_MSG_CHANNEL_CLOSE) { + if ($temp === true) { + if ($this->channel_status[self::CHANNEL] === NET_SSH2_MSG_CHANNEL_CLOSE) { $this->channel_close = true; } $this->packet_type = false;