mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-19461: Improve error message on listening error with IPv6 (#19462)
This commit is contained in:
4
NEWS
4
NEWS
@@ -13,6 +13,10 @@ PHP NEWS
|
||||
deprecated. (alexandre-daubois)
|
||||
. 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)
|
||||
|
||||
@@ -2563,7 +2563,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);
|
||||
}
|
||||
|
||||
41
sapi/cli/tests/php_cli_server_ipv4_error_message.phpt
Normal file
41
sapi/cli/tests/php_cli_server_ipv4_error_message.phpt
Normal 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
|
||||
"
|
||||
40
sapi/cli/tests/php_cli_server_ipv6_error_message.phpt
Normal file
40
sapi/cli/tests/php_cli_server_ipv6_error_message.phpt
Normal 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
|
||||
"
|
||||
Reference in New Issue
Block a user