summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Watkins <krakjoe@php.net>2018-09-04 11:12:57 +0200
committerJoe Watkins <krakjoe@php.net>2018-09-04 11:13:14 +0200
commit6b5e7e6b42d88f657ab85908799a47da7af4718c (patch)
tree81993150002b672bd8bf2454d828b869f66c001e
parent7585a20d4451597df301142393495ef508c0dde6 (diff)
parent21f8cd2a92fc105a0a782e35658389d0dc33a0c9 (diff)
downloadphp-git-6b5e7e6b42d88f657ab85908799a47da7af4718c.tar.gz
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2: Fix bug #74764 and add a test case
-rw-r--r--NEWS2
-rw-r--r--ext/standard/tests/network/bug74764.phpt24
-rw-r--r--main/network.c3
3 files changed, 29 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 5e95bd081b..0c96c3593f 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,8 @@ PHP NEWS
. Fixed bug #76818 (Memory corruption and segfault). (Remi)
. 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)
30 Aug 2018, PHP 7.3.0beta3
diff --git a/ext/standard/tests/network/bug74764.phpt b/ext/standard/tests/network/bug74764.phpt
new file mode 100644
index 0000000000..e946167008
--- /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 6a1ef981c1..7eccb36047 100644
--- a/main/network.c
+++ b/main/network.c
@@ -839,6 +839,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;