Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion main/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ PHPAPI void php_network_populate_name_from_sockaddr(
case AF_INET6:
buf = (char*)inet_ntop(sa->sa_family, &((struct sockaddr_in6*)sa)->sin6_addr, (char *)&abuf, sizeof(abuf));
if (buf) {
*textaddr = strpprintf(0, "%s:%d",
*textaddr = strpprintf(0, "[%s]:%d",
buf, ntohs(((struct sockaddr_in6*)sa)->sin6_port));
}

Expand Down
12 changes: 12 additions & 0 deletions tests/output/bug76136.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
Bug #76136: stream_socket_get_name should enclose IPv6 in brackets
--FILE--
<?php
$server = stream_socket_server("tcp://[::1]:1337/");
echo stream_socket_get_name($server, false).PHP_EOL;
$server = stream_socket_server("tcp://127.0.0.1:1337/");
echo stream_socket_get_name($server, false);
?>
--EXPECT--
[::1]:1337
127.0.0.1:1337