From 38a2a84da1c8ecccd57e5d2528293d3d03a7196d Mon Sep 17 00:00:00 2001 From: Kevin Reniers <22906111+kevinreniers@users.noreply.github.com> Date: Tue, 4 Jul 2023 15:01:48 +0200 Subject: [PATCH] Add EOF test to SSH2::isConnected This adds an additional test to SSH2::isConnected to make it more intuitive. Aside from testing against the internal state, it will also assert that there is an internal socket and that that socket has not reached EOF. --- phpseclib/Net/SSH2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index f43b54cb..ca1a08b1 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -3442,7 +3442,7 @@ class Net_SSH2 */ function isConnected() { - return (bool) ($this->bitmap & NET_SSH2_MASK_CONNECTED); + return ($this->bitmap & NET_SSH2_MASK_CONNECTED) && is_resource($this->fsock) && !feof($this->fsock); } /**