From 9651d075e3e023001e4581ef4b86fc04e1025593 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Fri, 29 May 2020 08:10:03 -0500 Subject: [PATCH] SSH2: timeout after 5s for channel closures --- phpseclib/Net/SSH2.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index cf73a38e..31af4453 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -3911,7 +3911,7 @@ class Net_SSH2 $this->channel_buffers[$channel][] = $data; break; case NET_SSH2_MSG_CHANNEL_CLOSE: - $this->curTimeout = 0; + $this->curTimeout = 5; if ($this->bitmap & NET_SSH2_MASK_SHELL) { $this->bitmap&= ~NET_SSH2_MASK_SHELL; @@ -4140,11 +4140,15 @@ class Net_SSH2 $this->channel_status[$client_channel] = NET_SSH2_MSG_CHANNEL_CLOSE; - $this->curTimeout = 0; + $this->curTimeout = 5; while (!is_bool($this->_get_channel_packet($client_channel))) { } + if ($this->is_timeout) { + $this->disconnect(); + } + if ($want_reply) { $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$client_channel])); }