From 52185327395894e0e7a795dfaad6b72cd02a8ba2 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 4 Apr 2020 12:17:55 -0500 Subject: [PATCH 1/2] SFTP: make it so extending SFTP doesn't cause a segfault --- phpseclib/Net/SFTP.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index a118d45e..f8650f89 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -467,7 +467,11 @@ class Net_SFTP extends Net_SSH2 */ function login($username) { - if (!call_user_func_array(array(&$this, 'parent::login'), func_get_args())) { + $args = func_get_args(); + $callback = version_compare(PHP_VERSION, '5.3.0') < 0 : + array(&$this, 'parent::login') : + 'parent::login'; + if (!call_user_func_array($callback, $args)) { return false; } From 91e84a24c292d583e4fdcd7e6b07b585d0f8a971 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 4 Apr 2020 12:20:36 -0500 Subject: [PATCH 2/2] SFTP: optimize call to parent login method for 2.0 branch --- phpseclib/Net/SFTP.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 28946396..bf7ef36b 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -412,11 +412,7 @@ class SFTP extends SSH2 */ function login($username) { - $args = func_get_args(); - $callback = version_compare(PHP_VERSION, '5.3.0') < 0 : - array(&$this, 'parent::login') : - 'parent::login'; - if (!call_user_func_array($callback, $args)) { + if (!call_user_func_array('parent::login', func_get_args())) { return false; }