From e2841212cb39de24849700b1ac52ef5f4c886211 Mon Sep 17 00:00:00 2001 From: Tom Sommer Date: Fri, 10 Jan 2020 11:58:36 +0100 Subject: [PATCH 1/3] Remove error suppression from stream_select() Suppressing errors from stream_select() makes debugging timeouts extremely hard. --- 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 59fba230..ba7f6d57 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -1245,7 +1245,7 @@ class SSH2 $usec = 1000000 * ($this->curTimeout - $sec); // on windows this returns a "Warning: Invalid CRT parameters detected" error // the !count() is done as a workaround for - if (!@stream_select($read, $write, $except, $sec, $usec) && !count($read)) { + if (stream_select($read, $write, $except, $sec, $usec) === false && !count($read)) { $this->is_timeout = true; return false; } From 40bd4192fca9ff5d2c5e4671dffded4c47944026 Mon Sep 17 00:00:00 2001 From: Tom Sommer Date: Fri, 17 Jan 2020 09:41:45 +0100 Subject: [PATCH 2/3] Update SSH2.php --- phpseclib/Net/SSH2.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index ba7f6d57..cb8872fc 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -1243,9 +1243,7 @@ class SSH2 $start = microtime(true); $sec = floor($this->curTimeout); $usec = 1000000 * ($this->curTimeout - $sec); - // on windows this returns a "Warning: Invalid CRT parameters detected" error - // the !count() is done as a workaround for - if (stream_select($read, $write, $except, $sec, $usec) === false && !count($read)) { + if (stream_select($read, $write, $except, $sec, $usec) === false) { $this->is_timeout = true; return false; } From 6470d1c80e1b670e1e16c04f2ad6c3ac38fc64b7 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Fri, 17 Jan 2020 06:38:54 -0600 Subject: [PATCH 3/3] SSH2: @stream_select -> stream_select --- phpseclib/Net/SSH2.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index c1ecae18..601ccac4 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -3586,7 +3586,7 @@ class SSH2 $write = $except = null; if (!$this->curTimeout) { - @stream_select($read, $write, $except, null); + stream_select($read, $write, $except, null); } else { if ($this->curTimeout < 0) { $this->is_timeout = true; @@ -3599,8 +3599,7 @@ class SSH2 $start = microtime(true); $sec = floor($this->curTimeout); $usec = 1000000 * ($this->curTimeout - $sec); - // on windows this returns a "Warning: Invalid CRT parameters detected" error - if (!@stream_select($read, $write, $except, $sec, $usec) && !count($read)) { + if (!stream_select($read, $write, $except, $sec, $usec)) { $this->is_timeout = true; if ($client_channel == self::CHANNEL_EXEC && !$this->request_pty) { $this->close_channel($client_channel);