From 585e0e44f487363326ff0900bccf4a75d0d5c70b Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 24 Aug 2023 20:20:11 -0500 Subject: [PATCH 1/2] ASN1: fix string conversion code for 32-bit PHP installs --- phpseclib/File/ASN1.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index fd078b2c..659b6f52 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -1592,7 +1592,7 @@ class File_ASN1 return false; } break; - case ($c & 0x80000000) != 0: + case ($c & (PHP_INT_SIZE == 8 ? 0x80000000 : (1 << 31))) != 0: return false; case $c >= 0x04000000: $v .= chr(0x80 | ($c & 0x3F)); From 0f23be3188b19fc7581e0e7677663594ef4cdee6 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 24 Aug 2023 20:20:47 -0500 Subject: [PATCH 2/2] SFTP: fix SFTPv2 errors when logging errors --- phpseclib/Net/SFTP.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 44e2487c..0bb6c7b3 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -926,7 +926,7 @@ class Net_SFTP extends Net_SSH2 $error = $this->status_codes[$status]; - if ($this->version > 2 || strlen($response) < 4) { + if ($this->version > 2) { extract(unpack('Nlength', $this->_string_shift($response, 4))); $this->sftp_errors[] = $error . ': ' . $this->_string_shift($response, $length); } else {