Skip to content

Commit ab9d10d

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Handle bindto error
2 parents 993be4b + 12bd3cc commit ab9d10d

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
@@ -747,6 +747,10 @@ static inline int php_tcp_sockop_connect(php_stream *stream, php_netstream_data_
747747
return -1;
748748
}
749749
bindto = parse_ip_address_ex(Z_STRVAL_P(tmpzval), Z_STRLEN_P(tmpzval), &bindport, xparam->want_errortext, &xparam->outputs.error_text);
750+
if (bindto == NULL) {
751+
efree(host);
752+
return -1;
753+
}
750754
}
751755

752756
#ifdef SO_BROADCAST

0 commit comments

Comments
 (0)