Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d84f463

Browse files
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix GH-19461: Improve error message on listening error with IPv6 (#19462)
2 parents 578783b + a41cb62 commit d84f463

File tree

4 files changed

+90
-1
lines changed

4 files changed

+90
-1
lines changed

‎NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ PHP NEWS
1313
. Fixed bug GH-19679 (zend_ssa_range_widening may fail to converge). (Arnaud)
1414
. Fixed bug GH-19681 (PHP_EXPAND_PATH broken with bash 5.3.0). (Remi)
1515

16+
- CLI:
17+
. Fixed bug GH-19461 (Improve error message on listening error with IPv6
18+
address). (alexandre-daubois)
19+
1620
- Date:
1721
. Fixed date_sunrise() and date_sunset() with partial-hour UTC offset.
1822
(ilutov)

‎sapi/cli/php_cli_server.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2562,7 +2562,11 @@ static zend_result php_cli_server_ctor(php_cli_server *server, const char *addr,
25622562

25632563
server_sock = php_network_listen_socket(host, &port, SOCK_STREAM, &server->address_family, &server->socklen, &errstr);
25642564
if (server_sock == SOCK_ERR) {
2565-
php_cli_server_logf(PHP_CLI_SERVER_LOG_ERROR, "Failed to listen on %s:%d (reason: %s)", host, port, errstr ? ZSTR_VAL(errstr) : "?");
2565+
if (strchr(host, ':')) {
2566+
php_cli_server_logf(PHP_CLI_SERVER_LOG_ERROR, "Failed to listen on [%s]:%d (reason: %s)", host, port, errstr ? ZSTR_VAL(errstr) : "?");
2567+
} else {
2568+
php_cli_server_logf(PHP_CLI_SERVER_LOG_ERROR, "Failed to listen on %s:%d (reason: %s)", host, port, errstr ? ZSTR_VAL(errstr) : "?");
2569+
}
25662570
if (errstr) {
25672571
zend_string_release_ex(errstr, 0);
25682572
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--TEST--
2+
IPv4 address error message formatting
3+
--SKIPIF--
4+
<?php
5+
if (substr(PHP_OS, 0, 3) == 'WIN') {
6+
die("skip not for Windows");
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
12+
$descriptorspec = array(
13+
0 => array("pipe", "r"),
14+
1 => array("pipe", "w"),
15+
2 => array("pipe", "w")
16+
);
17+
18+
$process = proc_open(
19+
PHP_BINARY . ' -S "192.168.1.999:8080"',
20+
$descriptorspec,
21+
$pipes
22+
);
23+
24+
if (is_resource($process)) {
25+
usleep(100000);
26+
27+
$stderr = stream_get_contents($pipes[2]);
28+
29+
fclose($pipes[0]);
30+
fclose($pipes[1]);
31+
fclose($pipes[2]);
32+
33+
proc_terminate($process);
34+
proc_close($process);
35+
36+
var_dump($stderr);
37+
}
38+
?>
39+
--EXPECTF--
40+
string(%d) "[%s] Failed to listen on 192.168.1.999:8080 %s
41+
"
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
IPv6 address error message formatting
3+
--SKIPIF--
4+
<?php
5+
if (substr(PHP_OS, 0, 3) == 'WIN') {
6+
die("skip not for Windows");
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
$descriptorspec = array(
12+
0 => array("pipe", "r"),
13+
1 => array("pipe", "w"),
14+
2 => array("pipe", "w")
15+
);
16+
17+
$process = proc_open(
18+
PHP_BINARY . ' -S "[2001:db8::]:8080"',
19+
$descriptorspec,
20+
$pipes
21+
);
22+
23+
if (is_resource($process)) {
24+
usleep(100000);
25+
26+
$stderr = stream_get_contents($pipes[2]);
27+
28+
fclose($pipes[0]);
29+
fclose($pipes[1]);
30+
fclose($pipes[2]);
31+
32+
proc_terminate($process);
33+
proc_close($process);
34+
35+
var_dump($stderr);
36+
}
37+
?>
38+
--EXPECTF--
39+
string(%d) "[%s] Failed to listen on [2001:db8::]:8080 %s
40+
"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /