com php-src: Fix bug #74764 and add a test case: NEWS ext/standard/tests/network/bug74764.phpt main/network.c

From: Date: Tue, 04 Sep 2018 09:12:04 +0000
Subject: com php-src: Fix bug #74764 and add a test case: NEWS ext/standard/tests/network/bug74764.phpt main/network.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-102991@lists.php.net to get a copy of this message
Commit: 0f724453c03b7ff500563c019f5dab736d326ad8 Author: Ville Hukkamaki <vhu@iki.fi> Tue, 28 Aug 2018 23:26:13 +0200 Committer: Joe Watkins <krakjoe@php.net> Tue, 4 Sep 2018 11:12:04 +0200 Parents: e58690a26d5e3800c26d24ea30d4e5a1367f096d Branches: PHP-7.1 PHP-7.2 PHP-7.3 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0f724453c03b7ff500563c019f5dab736d326ad8 Log: Fix bug #74764 and add a test case Bugs: https://bugs.php.net/74764 Changed paths: M NEWS A ext/standard/tests/network/bug74764.phpt M main/network.c Diff: diff --git a/NEWS b/NEWS index 7201448..ea1fd8e 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,8 @@ PHP NEWS - Standard: . Fixed bug #73457 (Wrong error message when fopen FTP wrapped fails to open data connection). (Ville Hukkamäki) + . Fixed bug #74764 (Bindto IPv6 works with file_get_contents but fails with + stream_socket_client). (Ville Hukkamäki) 13 Sep 2018, PHP 7.1.22 diff --git a/ext/standard/tests/network/bug74764.phpt b/ext/standard/tests/network/bug74764.phpt new file mode 100644 index 0000000..e946167 --- /dev/null +++ b/ext/standard/tests/network/bug74764.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #74764 IPv6 bindto fails with stream_socket_client() +--SKIPIF-- +<?php +/* following copied straight from the tcp6loop.phpt */ +@stream_socket_client('tcp://[::1]:0', $errno); +if ($errno != 111) die('skip IPv6 not supported.'); +?> +--FILE-- +<?php +$context = stream_context_create( + ['socket' => array('bindto' => "[::]:0")] + ); + $socket = stream_socket_client('tcp://localhost:1443', $errno, $errstr, 5, STREAM_CLIENT_CONNECT, $context); + +$context = stream_context_create( + array('socket' => array('bindto' => "0.0.0.0:0")) + ); + $socket = stream_socket_client('tcp://localhost:1443', $errno, $errstr, 5, STREAM_CLIENT_CONNECT, $context); +?> +--EXPECTF-- +Warning: stream_socket_client(): unable to connect to tcp://localhost:1443 (%s) in %s on line %d + +Warning: stream_socket_client(): unable to connect to tcp://localhost:1443 (%s) in %s on line %d diff --git a/main/network.c b/main/network.c index 8a32636..145911d 100644 --- a/main/network.c +++ b/main/network.c @@ -863,6 +863,9 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short int local_address_len = 0; if (sa->sa_family == AF_INET) { + if (strchr(bindto,':')) { + goto skip_bind; + } struct sockaddr_in *in4 = emalloc(sizeof(struct sockaddr_in)); local_address = (struct sockaddr*)in4;

« previous php.cvs (#102991) next »