1
0
mirror of https://github.com/php/php-src.git synced 2026-04-13 19:14:16 +02:00

Merge branch 'master' of git.php.net:/php-src

* 'master' of git.php.net:/php-src:
  Fix bug #74764 and add a test case
  [ci skip] Update NEWS
  [ci skip] Update NEWS
  [ci skip] Update NEWS
This commit is contained in:
Xinchen Hui
2018-09-04 17:27:30 +08:00
3 changed files with 30 additions and 0 deletions

3
NEWS
View File

@@ -2,5 +2,8 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 7.4.0alpha1
- Standard:
. Fixed bug #74764 (Bindto IPv6 works with file_get_contents but fails with
stream_socket_client). (Ville Hukkamäki)
<<< NOTE: Insert NEWS from last stable release here prior to actual release! >>>

View File

@@ -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

View File

@@ -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;