[php-src] master: Merge branch 'PHP-8.3'

From: Date: Fri, 29 Mar 2024 16:33:55 +0000
Subject: [php-src] master: Merge branch 'PHP-8.3'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-127887@lists.php.net to get a copy of this message
Author: Jakub Zelenka (bukka) Date: 2024-03-29T16:33:44Z Commit: https://github.com/php/php-src/commit/09f5e7921e27acf54e4defd786a4b1adaec9fd9c Raw diff: https://github.com/php/php-src/commit/09f5e7921e27acf54e4defd786a4b1adaec9fd9c.diff Merge branch 'PHP-8.3' Changed paths: M ext/openssl/tests/ServerClientTestCase.inc M ext/openssl/tests/gh10495.phpt Diff: diff --git a/ext/openssl/tests/ServerClientTestCase.inc b/ext/openssl/tests/ServerClientTestCase.inc index 1b140b63f6b4..0d67d7f7b2d8 100644 --- a/ext/openssl/tests/ServerClientTestCase.inc +++ b/ext/openssl/tests/ServerClientTestCase.inc @@ -26,6 +26,35 @@ function phpt_has_sslv3() { return $result; } +function phpt_extract_tls_records($rawData) { + $records = []; + $offset = 0; + $dataLength = strlen($rawData); + + while ($offset < $dataLength) { + // Ensure there's enough data left for the header. + if ($offset + 5 > $dataLength) { + break; + } + + // Extract the length of the current record. + $length = unpack("n", substr($rawData, $offset + 3, 2))[1]; + + // Check if the total length is within the bounds of the rawData. + if ($offset + 5 + $length > $dataLength) { + break; + } + + // Extract the record and add it to the records array. + $records[] = substr($rawData, $offset, 5 + $length); + + // Move the offset past the current record. + $offset += 5 + $length; + } + + return $records; +} + /** * This is a singleton to let the wait/notify functions work * I know it's horrible, but it's a means to an end diff --git a/ext/openssl/tests/gh10495.phpt b/ext/openssl/tests/gh10495.phpt index 3ed5a3d384b6..7c743d8de50a 100644 --- a/ext/openssl/tests/gh10495.phpt +++ b/ext/openssl/tests/gh10495.phpt @@ -63,25 +63,26 @@ $proxyCode = <<<'CODE' $read = [$upstream, $conn]; $applicationData = false; - $i = 1; while (stream_select($read, $write, $except, 1)) { foreach ($read as $fp) { $data = stream_get_contents($fp); if ($fp === $conn) { fwrite($upstream, $data); } else { - if ($data !== '' && $data[0] === chr(23)) { - if (!$applicationData) { - $applicationData = true; - fwrite($conn, $data[0]); - phpt_notify(); - sleep(1); - fwrite($conn, substr($data, 1)); + foreach (phpt_extract_tls_records($data) as $record) { + if ($record !== '' && $record[0] === chr(23)) { + if (!$applicationData) { + $applicationData = true; + fwrite($conn, $record[0]); + phpt_notify(); + sleep(1); + fwrite($conn, substr($record, 1)); + } else { + fwrite($conn, $record); + } } else { - fwrite($conn, $data); + fwrite($conn, $record); } - } else { - fwrite($conn, $data); } } }

« previous php.cvs (#127887) next »