Skip to content

Commit 12bd3cc

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Handle bindto error
2 parents e1f6ab3 + 0b8c83f commit 12bd3cc

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Test invalid bindto
3+
--FILE--
4+
<?php
5+
$ctx = stream_context_create([
6+
'socket' => [
7+
'bindto' => 'invalid',
8+
],
9+
]);
10+
$fp = stream_socket_client(
11+
'tcp://www.' . str_repeat('x', 100) . '.com:80',
12+
$errno, $errstr, 30, STREAM_CLIENT_CONNECT, $ctx
13+
);
14+
?>
15+
--EXPECTF--
16+
Warning: stream_socket_client(): Unable to connect to tcp://%s:80 (Failed to parse address "invalid") in %s on line %d

main/streams/xp_socket.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,10 @@ static inline int php_tcp_sockop_connect(php_stream *stream, php_netstream_data_
750750
return -1;
751751
}
752752
bindto = parse_ip_address_ex(Z_STRVAL_P(tmpzval), Z_STRLEN_P(tmpzval), &bindport, xparam->want_errortext, &xparam->outputs.error_text);
753+
if (bindto == NULL) {
754+
efree(host);
755+
return -1;
756+
}
753757
}
754758

755759
#ifdef SO_BROADCAST

0 commit comments

Comments
 (0)