com php-src: Fixed bug #76136 (stream_socket_get_name enclosed IPv6 in brackets): NEWS UPGRADING ext/standard/tests/streams/bug76136.phpt main/
network.c

From: Date: Sat, 07 Jul 2018 09:47:50 +0000
Subject: com php-src: Fixed bug #76136 (stream_socket_get_name enclosed IPv6 in brackets): NEWS UPGRADING ext/standard/tests/streams/bug76136.phpt main/
network.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-102464@lists.php.net to get a copy of this message
Commit: 95013042bf85ce1f52e476c5cc301faa97f52a72 Author: seliver <alexeyseliverstov.dev@gmail.com> Sat, 31 Mar 2018 04:05:12 +0100 Committer: Nikita Popov <nikita.ppv@gmail.com> Sat, 7 Jul 2018 11:47:50 +0200 Parents: 67352cb2c01706b75d9a6f2793a2022f4751e355 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=95013042bf85ce1f52e476c5cc301faa97f52a72 Log: 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. Bugs: https://bugs.php.net/76136 Changed paths: M NEWS M UPGRADING A ext/standard/tests/streams/bug76136.phpt M main/network.c Diff: diff --git a/NEWS b/NEWS index 7184825..ceb4780 100644 --- a/NEWS +++ b/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: diff --git a/UPGRADING b/UPGRADING index 98daa08..54bb277 100644 --- a/UPGRADING +++ b/UPGRADING @@ -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 diff --git a/ext/standard/tests/streams/bug76136.phpt b/ext/standard/tests/streams/bug76136.phpt new file mode 100644 index 0000000..687d4ae --- /dev/null +++ b/ext/standard/tests/streams/bug76136.phpt @@ -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 diff --git a/main/network.c b/main/network.c index 03ceb2a..b31e9d6 100644 --- a/main/network.c +++ b/main/network.c @@ -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)); }

« previous php.cvs (#102464) next »