diff --git a/build/psalm_baseline.xml b/build/psalm_baseline.xml index 8123382b..27caa7b2 100644 --- a/build/psalm_baseline.xml +++ b/build/psalm_baseline.xml @@ -7624,12 +7624,6 @@ $key - - $key - - - $key - loadParameters loadPublicKey @@ -10720,7 +10714,7 @@ - + !is_array($this->currentCert) !is_array($this->currentCert) !is_array($this->currentCert) @@ -10733,6 +10727,7 @@ !isset($this->currentCert) !isset($this->currentCert) !isset($this->currentCert) + $cert === false false @@ -10748,9 +10743,8 @@ new BigInteger($serial, $base) - + $j - $value string @@ -11317,7 +11311,10 @@ false false - + + $cert + $cert + $cert $crl $csr $date @@ -11332,11 +11329,12 @@ $results[$i + 1] $results[$i] - + + $cert + $cert $date $date $dn - $value __toString @@ -11346,8 +11344,7 @@ $key->getCurve() - - $cert + $csr @@ -11492,8 +11489,7 @@ signCRL unrevoke - - \phpseclib3\File\X509 + bool bool bool @@ -11579,12 +11575,11 @@ $root $spkac - + !is_array($cert) !is_array($crl) !is_array($csr) !is_array($spkac) - $cert === false $crl === false $csr === false $spkac === false @@ -11597,7 +11592,6 @@ 'sha256' 'sha384' 'sha384' - is_array($cert) is_array($crl) is_array($csr) is_array($root) @@ -14987,9 +14981,11 @@ bool - + $defaultVersion $version + SFTP + SFTP (int) $ver @@ -15263,28 +15259,32 @@ bool|SSH2 + + $this->curTimeout -= $elapsed + $this->curTimeout -= $elapsed + $this->curTimeout -= $elapsed + $this->curTimeout -= $elapsed + $this->curTimeout -= $elapsed + array{Hash, int}|null string - + $algorithm $host $password - $timeout - - $curTimeout + $keepAlive $quiet_mode $realtime_log_wrap - $timeout connect get_channel_packet - + $a['comp'] $a['crypt'] $a['mac'] @@ -15369,9 +15369,6 @@ $this->channel_buffers[$client_channel] $this->compression_algorithms_client_to_server $this->compression_algorithms_server_to_client - $this->curTimeout - $this->curTimeout - $this->curTimeout == 0 ? 100000 : $this->curTimeout $this->encryption_algorithms_client_to_server $this->encryption_algorithms_server_to_client $this->keepAlive @@ -15531,7 +15528,7 @@ sign withHash - + $curveName $data $data @@ -15554,13 +15551,6 @@ $temp $temp $temp - $this->curTimeout - $this->curTimeout - $this->curTimeout - $this->curTimeout - $this->curTimeout - $this->curTimeout - $this->curTimeout $this->errors[count($this->errors) - 1] $this->window_size_client_to_server[$channel] $this->window_size_client_to_server[$client_channel] @@ -15675,9 +15665,11 @@ false inflate_init(ZLIB_ENCODING_RAW, ['window' => $cinfo + 8]) - + $args $engine + $password + $password $response $response $response @@ -15785,8 +15777,9 @@ ($callback is callable ? bool : string|bool) - + $agent + $curTimeout $decompress_context $exit_status $hmac_check_etm @@ -15803,7 +15796,11 @@ $realtime_log_size $server_public_host_key $stdErrorLog + $timeout + + is_array($responses[$i]) + $this->session_id !== false Strings::is_stringable($arg) @@ -15880,27 +15877,21 @@ $address - + $agent_reply_bytes - $agent_reply_data $key $key_blob $key_blob $length - $packet $temp - $this->readBytes(4) - $this->readBytes(4) - + $address $address $agent_data_bytes $agent_reply_bytes $agent_reply_data - $agent_reply_data $length - $packet $temp $this->expected_bytes @@ -15941,15 +15932,12 @@ - + $length - $packet $signature_blob - $this->readBytes(4) - + $length - $packet string @@ -15981,15 +15969,6 @@ $type - - - readBytes - - - $temp - $temp - - ini_get('mbstring.func_overload') diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index c87c2475..480c0299 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -279,11 +279,6 @@ class X509 */ private $domains = null; - /** - * Default Constructor. - * - * @return \phpseclib3\File\X509 - */ public function __construct() { // Explicitly Tagged Module, 1988 Syntax @@ -430,8 +425,10 @@ class X509 * Load X.509 certificate * * Returns an associative array describing the X.509 cert or a false if the cert failed to load + * + * @param string|array $cert */ - public function loadX509(string $cert, int $mode = self::FORMAT_AUTO_DETECT) + public function loadX509($cert, int $mode = self::FORMAT_AUTO_DETECT) { if (is_array($cert) && isset($cert['tbsCertificate'])) { unset($this->currentCert); diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 154ea153..cfb866d1 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -706,14 +706,16 @@ class SSH2 /** * Timeout * - * @see self::setTimeout() + * @see SSH2::setTimeout() + * @var int */ protected $timeout; /** * Current Timeout * - * @see self::get_channel_packet() + * @see SSH2::get_channel_packet() + * @var int */ protected $curTimeout; @@ -2253,10 +2255,9 @@ class SSH2 /** * Handle the keyboard-interactive requests / responses. * - * @param string|array ...$responses * @throws \RuntimeException on connection error */ - private function keyboard_interactive_process(...$responses): bool + private function keyboard_interactive_process(array ...$responses): bool { if (strlen($this->last_interactive_response)) { $response = $this->last_interactive_response; @@ -2498,7 +2499,7 @@ class SSH2 * $ssh->exec('ping 127.0.0.1'); on a Linux host will never return and will run indefinitely. setTimeout() makes it so it'll timeout. * Setting $timeout to false or 0 will mean there is no timeout. */ - public function setTimeout($timeout): void + public function setTimeout(int $timeout): void { $this->timeout = $this->curTimeout = $timeout; } diff --git a/phpseclib/System/SSH/Common/Traits/ReadBytes.php b/phpseclib/System/SSH/Common/Traits/ReadBytes.php index 6e1ef5b5..b71b7bbc 100644 --- a/phpseclib/System/SSH/Common/Traits/ReadBytes.php +++ b/phpseclib/System/SSH/Common/Traits/ReadBytes.php @@ -27,10 +27,13 @@ trait ReadBytes * * @throws \RuntimeException on connection errors */ - public function readBytes(int $length) + public function readBytes(int $length): string { $temp = fread($this->fsock, $length); - if (strlen($temp) != $length) { + if ($temp === false) { + throw new \RuntimeException('\fread() failed.'); + } + if (strlen($temp) !== $length) { throw new \RuntimeException("Expected $length bytes; got " . strlen($temp)); } return $temp;