mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Fixed bug #76136 (stream_socket_get_name enclosed IPv6 in brackets)
The IPv6 IP of a socket is provided by inet_ntop() as a string, but this function doesn't enclose the IP in brackets. This patch adds them in the php_network_populate_name_from_sockaddr() function.
This commit is contained in:
parent
67352cb2c0
commit
95013042bf
4
NEWS
4
NEWS
@ -14,6 +14,10 @@ PHP NEWS
|
||||
for FIREBIRD >= 3.0). (Dorin Marcoci)
|
||||
. Fixed bug #76488 (Memory leak when fetching a BLOB field). (Simonov Denis)
|
||||
|
||||
- Standard:
|
||||
. Fixed bug #76136 (stream_socket_get_name should enclose IPv6 in brackets).
|
||||
(seliver)
|
||||
|
||||
05 Jul 2018, PHP 7.3.0alpha3
|
||||
|
||||
- Core:
|
||||
|
@ -152,8 +152,10 @@ SimpleXML:
|
||||
Standard:
|
||||
. Undefined variables passed to compact() will now be reported as a notice.
|
||||
. getimagesize() and related functions now report the mime type of BMP images
|
||||
as image/bmp instead of image/x-ms-bmp, since the former has been registered
|
||||
with the IANA (see RFC 7903).
|
||||
as image/bmp instead of image/x-ms-bmp, since the former has been registered
|
||||
with the IANA (see RFC 7903).
|
||||
. stream_socket_get_name() will now return IPv6 addresses wrapped in brackets.
|
||||
For example "[::1]:1337" will be returned instead of "::1:1337".
|
||||
|
||||
========================================
|
||||
2. New Features
|
||||
|
19
ext/standard/tests/streams/bug76136.phpt
Normal file
19
ext/standard/tests/streams/bug76136.phpt
Normal file
@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
Bug #76136: stream_socket_get_name should enclose IPv6 in brackets
|
||||
--SKIPIF--
|
||||
<?php
|
||||
@stream_socket_client('tcp://[::1]:0', $errno);
|
||||
if ($errno != 111) {
|
||||
die('skip IPv6 is not supported.');
|
||||
}
|
||||
?>
|
||||
--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
|
@ -626,7 +626,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));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user