From cd21287ebcb15f77e4ad2107dac43efa8004d494 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Mon, 16 Sep 2019 07:55:47 -0500 Subject: [PATCH 1/2] SSH2: only do fclose($this->fsock) if doing so won't yield error --- phpseclib/Net/SSH2.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index d7124041..571e4c99 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -4157,7 +4157,9 @@ class Net_SSH2 } $this->bitmap = 0; - fclose($this->fsock); + if (is_resource($this->fsock) && get_resource_type($this->fsock) == 'stream') { + fclose($this->fsock); + } return false; } From 05ea3eafb85c1caaabc49efd3b7d39348c5f8e07 Mon Sep 17 00:00:00 2001 From: Jamiel <20553479+jamielsharief@users.noreply.github.com> Date: Mon, 16 Sep 2019 23:04:07 +0200 Subject: [PATCH 2/2] #1405 --- phpseclib/Net/SSH2.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index d7124041..571e4c99 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -4157,7 +4157,9 @@ class Net_SSH2 } $this->bitmap = 0; - fclose($this->fsock); + if (is_resource($this->fsock) && get_resource_type($this->fsock) == 'stream') { + fclose($this->fsock); + } return false; }