From 2026b0c0db7f4b027af4da07b6223534dca13d23 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 27 Aug 2022 07:59:39 -0500 Subject: [PATCH] Hash: fix PHP 8.2 error see https://github.com/php/php-src/issues/8924 --- phpseclib/Crypt/Hash.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpseclib/Crypt/Hash.php b/phpseclib/Crypt/Hash.php index 8f95772f..0e02544e 100644 --- a/phpseclib/Crypt/Hash.php +++ b/phpseclib/Crypt/Hash.php @@ -575,10 +575,10 @@ class Hash // For the last chunk: pad to 32-byte boundary, endian-adjust, // NH hash and add bit-length. Concatenate the result to Y. // - $length = strlen($m[$i]); + $length = count($m) ? strlen($m[$i]) : 0; $pad = 32 - ($length % 32); $pad = max(32, $length + $pad % 32); - $m[$i] = str_pad($m[$i], $pad, "\0"); // zeropad + $m[$i] = str_pad(isset($m[$i]) ? $m[$i] : '', $pad, "\0"); // zeropad $m[$i] = pack('N*', ...unpack('V*', $m[$i])); // ENDIAN-SWAP $y .= static::nh($k, $m[$i], new BigInteger($length * 8));