Skip to content

Commit 48fd1d2

Browse files
committed
Merge branch 'PHP-7.3' of git.php.net:/php-src into PHP-7.3
* 'PHP-7.3' 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
2 parents 3497b75 + 6b5e7e6 commit 48fd1d2

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Bug #74764 IPv6 bindto fails with stream_socket_client()
3+
--SKIPIF--
4+
<?php
5+
/* following copied straight from the tcp6loop.phpt */
6+
@stream_socket_client('tcp://[::1]:0', $errno);
7+
if ($errno != 111) die('skip IPv6 not supported.');
8+
?>
9+
--FILE--
10+
<?php
11+
$context = stream_context_create(
12+
['socket' => array('bindto' => "[::]:0")]
13+
);
14+
$socket = stream_socket_client('tcp://localhost:1443', $errno, $errstr, 5, STREAM_CLIENT_CONNECT, $context);
15+
16+
$context = stream_context_create(
17+
array('socket' => array('bindto' => "0.0.0.0:0"))
18+
);
19+
$socket = stream_socket_client('tcp://localhost:1443', $errno, $errstr, 5, STREAM_CLIENT_CONNECT, $context);
20+
?>
21+
--EXPECTF--
22+
Warning: stream_socket_client(): unable to connect to tcp://localhost:1443 (%s) in %s on line %d
23+
24+
Warning: stream_socket_client(): unable to connect to tcp://localhost:1443 (%s) in %s on line %d

main/network.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,9 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short
839839
int local_address_len = 0;
840840

841841
if (sa->sa_family == AF_INET) {
842+
if (strchr(bindto,':')) {
843+
goto skip_bind;
844+
}
842845
struct sockaddr_in *in4 = emalloc(sizeof(struct sockaddr_in));
843846

844847
local_address = (struct sockaddr*)in4;

0 commit comments

Comments
 (0)