From 8f31e59efaaa0de31449d97e4470cb5d3bc09c81 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 20 Mar 2021 06:00:23 -0500 Subject: [PATCH 1/4] ... --- phpseclib/Crypt/Common/SymmetricKey.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpseclib/Crypt/Common/SymmetricKey.php b/phpseclib/Crypt/Common/SymmetricKey.php index c56d44b3..7281d00f 100644 --- a/phpseclib/Crypt/Common/SymmetricKey.php +++ b/phpseclib/Crypt/Common/SymmetricKey.php @@ -2447,6 +2447,8 @@ abstract class SymmetricKey self::MODE_STREAM => MCRYPT_MODE_STREAM, ]; + set_error_handler(function() {}); + $this->demcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); $this->enmcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); @@ -2456,6 +2458,8 @@ abstract class SymmetricKey if ($this->mode == self::MODE_CFB) { $this->ecb = mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, ''); } + + restore_error_handler(); } // else should mcrypt_generic_deinit be called? if ($this->mode == self::MODE_CFB) { From 78364b0127ae773e220ddd23d2f99ff6c35faee5 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 20 Mar 2021 06:09:38 -0500 Subject: [PATCH 2/4] ... --- phpseclib/Crypt/Common/SymmetricKey.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/phpseclib/Crypt/Common/SymmetricKey.php b/phpseclib/Crypt/Common/SymmetricKey.php index 7281d00f..605458e0 100644 --- a/phpseclib/Crypt/Common/SymmetricKey.php +++ b/phpseclib/Crypt/Common/SymmetricKey.php @@ -2436,6 +2436,8 @@ abstract class SymmetricKey case self::ENGINE_MCRYPT: $this->enchanged = $this->dechanged = true; + set_error_handler(function() {}); + if (!isset($this->enmcrypt)) { static $mcrypt_modes = [ self::MODE_CTR => 'ctr', @@ -2447,8 +2449,6 @@ abstract class SymmetricKey self::MODE_STREAM => MCRYPT_MODE_STREAM, ]; - set_error_handler(function() {}); - $this->demcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); $this->enmcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); @@ -2459,12 +2459,14 @@ abstract class SymmetricKey $this->ecb = mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, ''); } - restore_error_handler(); } // else should mcrypt_generic_deinit be called? if ($this->mode == self::MODE_CFB) { mcrypt_generic_init($this->ecb, $this->key, str_repeat("\0", $this->block_size)); } + + restore_error_handler(); + break; case self::ENGINE_INTERNAL: $this->setupKey(); From b7eaee4977b02f610ac01d0b2d4f733f3b82e8d1 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Fri, 9 Apr 2021 10:55:50 -0500 Subject: [PATCH 3/4] don't load plugins whose filename start with a . --- phpseclib/Crypt/Common/AsymmetricKey.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpseclib/Crypt/Common/AsymmetricKey.php b/phpseclib/Crypt/Common/AsymmetricKey.php index b78c9d5c..7fa451c7 100644 --- a/phpseclib/Crypt/Common/AsymmetricKey.php +++ b/phpseclib/Crypt/Common/AsymmetricKey.php @@ -351,6 +351,9 @@ abstract class AsymmetricKey continue; } $name = $file->getBasename('.php'); + if ($name[0] == '.') { + continue; + } $type = 'phpseclib3\Crypt\\' . static::ALGORITHM . '\\Formats\\' . $format . '\\' . $name; $reflect = new \ReflectionClass($type); if ($reflect->isTrait()) { From 4e1093fc22fba8a47d1b07107f53d552bfd5a9f9 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Mon, 12 Apr 2021 06:17:04 -0500 Subject: [PATCH 4/4] CS adjustments --- phpseclib/Net/SFTP.php | 4 ++-- phpseclib/Net/SSH2.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index bea04714..5303a3a8 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -272,7 +272,7 @@ class SFTP extends SSH2 * @var array * @access private */ - var $requestBuffer = array(); + private $requestBuffer = array(); /** * Preserve timestamps on file downloads / uploads @@ -282,7 +282,7 @@ class SFTP extends SSH2 * @var bool * @access private */ - var $preserveTime = false; + private $preserveTime = false; /** * Default Constructor. diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 598c59b6..0dd52922 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -640,7 +640,7 @@ class SSH2 * @see self::exec() * @access private */ - var $window_resize = 0x40000000; + private $window_resize = 0x40000000; /** * Window size, server to client @@ -729,7 +729,7 @@ class SSH2 * @see self::setKeepAlive() * @access private */ - var $keepAlive; + private $keepAlive; /** * Real-time log file pointer