[php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5

From: Date: Tue, 29 Sep 2026 00:08:38 +0000
Subject: [php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141661@lists.php.net to get a copy of this message
Author: Ilia Alshanetsky (iliaal) Date: 2026-09-28T19:55:04-04:00 Commit: https://github.com/php/php-src/commit/026e6675b2c075437d22a205dff9c4356ac9a1f7 Raw diff: https://github.com/php/php-src/commit/026e6675b2c075437d22a205dff9c4356ac9a1f7.diff Merge branch 'PHP-8.4' into PHP-8.5 * PHP-8.4: ext/openssl: Restore blocking mode after a handshake timeout Changed paths: A ext/openssl/tests/stream_crypto_enable_timeout_blocking.phpt M NEWS M ext/openssl/xp_ssl.c Diff: diff --git a/NEWS b/NEWS index 21e955af50aa..0f2af2c21ca9 100644 --- a/NEWS +++ b/NEWS @@ -84,6 +84,10 @@ PHP NEWS child's shadowing public property). (Ilia Alshanetsky) . Fix incorrect DCE due to unsound escape analysis. (ndossche) +- OpenSSL: + . Fixed stream_socket_enable_crypto() leaving the socket non-blocking + after a handshake timeout. (Ilia Alshanetsky) + - PCNTL: . Fixed pcntl_signal_dispatch() dropping the queued signals when it runs while an exception is pending. (nicolas-grekas) diff --git a/ext/openssl/tests/stream_crypto_enable_timeout_blocking.phpt b/ext/openssl/tests/stream_crypto_enable_timeout_blocking.phpt new file mode 100644 index 000000000000..39a8f973b866 --- /dev/null +++ b/ext/openssl/tests/stream_crypto_enable_timeout_blocking.phpt @@ -0,0 +1,53 @@ +--TEST-- +OpenSSL handshake timeout restores the stream blocking mode +--EXTENSIONS-- +openssl +--SKIPIF-- +<?php +if (!function_exists('proc_open')) die('skip no proc_open'); +?> +--FILE-- +<?php +$serverCode = <<<'CODE' + $server = stream_socket_server('tcp://127.0.0.1:0', $errno, $errstr); + phpt_notify_server_start($server); + + $conn = stream_socket_accept($server, 5); + phpt_wait(); + fclose($conn); +CODE; + +$clientCode = <<<'CODE' + $context = stream_context_create(['ssl' => [ + 'verify_peer' => false, + 'verify_peer_name' => false, + ]]); + $client = stream_socket_client('tcp://{{ ADDR }}', $errno, $errstr, 1, STREAM_CLIENT_CONNECT, $context); + + $metadata = stream_get_meta_data($client); + var_dump($metadata['blocked']); + + set_error_handler(function (int $errno, string $errstr) use ($client): bool { + $metadata = stream_get_meta_data($client); + var_dump($metadata['blocked']); + echo $errstr, "\n"; + fclose($client); + return true; + }); + + var_dump(stream_socket_enable_crypto($client, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)); + restore_error_handler(); + var_dump(is_resource($client)); + + phpt_notify(); +CODE; + +include 'ServerClientTestCase.inc'; +ServerClientTestCase::getInstance()->run($clientCode, $serverCode); +?> +--EXPECT-- +bool(true) +bool(true) +stream_socket_enable_crypto(): SSL: Handshake timed out +bool(false) +bool(false) diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index 10e10691bda0..e58bab90d0aa 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -1885,6 +1885,7 @@ static int php_openssl_enable_crypto(php_stream *stream, elapsed_time = php_openssl_subtract_timeval(cur_time, start_time); if (php_openssl_compare_timeval( elapsed_time, *timeout) > 0) { + php_openssl_set_blocking(sslsock, blocked); php_error_docref(NULL, E_WARNING, "SSL: Handshake timed out"); return -1; }

« previous php.cvs (#141661) next »