1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.3' into PHP-8.4

* PHP-8.3:
  Fix GH-19461: Improve error message on listening error with IPv6 (#19462)
This commit is contained in:
Alexandre Daubois
2025-09-05 10:50:11 +02:00
4 changed files with 90 additions and 1 deletions

4
NEWS
View File

@@ -13,6 +13,10 @@ PHP NEWS
. Fixed bug GH-19679 (zend_ssa_range_widening may fail to converge). (Arnaud)
. Fixed bug GH-19681 (PHP_EXPAND_PATH broken with bash 5.3.0). (Remi)
- CLI:
. Fixed bug GH-19461 (Improve error message on listening error with IPv6
address). (alexandre-daubois)
- Date:
. Fixed date_sunrise() and date_sunset() with partial-hour UTC offset.
(ilutov)

View File

@@ -2562,7 +2562,11 @@ static zend_result php_cli_server_ctor(php_cli_server *server, const char *addr,
server_sock = php_network_listen_socket(host, &port, SOCK_STREAM, &server->address_family, &server->socklen, &errstr);
if (server_sock == SOCK_ERR) {
php_cli_server_logf(PHP_CLI_SERVER_LOG_ERROR, "Failed to listen on %s:%d (reason: %s)", host, port, errstr ? ZSTR_VAL(errstr) : "?");
if (strchr(host, ':')) {
php_cli_server_logf(PHP_CLI_SERVER_LOG_ERROR, "Failed to listen on [%s]:%d (reason: %s)", host, port, errstr ? ZSTR_VAL(errstr) : "?");
} else {
php_cli_server_logf(PHP_CLI_SERVER_LOG_ERROR, "Failed to listen on %s:%d (reason: %s)", host, port, errstr ? ZSTR_VAL(errstr) : "?");
}
if (errstr) {
zend_string_release_ex(errstr, 0);
}

View File

@@ -0,0 +1,41 @@
--TEST--
IPv4 address error message formatting
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') {
die("skip not for Windows");
}
?>
--FILE--
<?php
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "w")
);
$process = proc_open(
PHP_BINARY . ' -S "192.168.1.999:8080"',
$descriptorspec,
$pipes
);
if (is_resource($process)) {
usleep(100000);
$stderr = stream_get_contents($pipes[2]);
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_terminate($process);
proc_close($process);
var_dump($stderr);
}
?>
--EXPECTF--
string(%d) "[%s] Failed to listen on 192.168.1.999:8080 %s
"

View File

@@ -0,0 +1,40 @@
--TEST--
IPv6 address error message formatting
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') {
die("skip not for Windows");
}
?>
--FILE--
<?php
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "w")
);
$process = proc_open(
PHP_BINARY . ' -S "[2001:db8::]:8080"',
$descriptorspec,
$pipes
);
if (is_resource($process)) {
usleep(100000);
$stderr = stream_get_contents($pipes[2]);
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_terminate($process);
proc_close($process);
var_dump($stderr);
}
?>
--EXPECTF--
string(%d) "[%s] Failed to listen on [2001:db8::]:8080 %s
"