mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
Handle bindto error
Closes GH-5903.
This commit is contained in:
parent
9a744c66e7
commit
0b8c83f593
16
ext/standard/tests/network/bindto.phpt
Normal file
16
ext/standard/tests/network/bindto.phpt
Normal file
@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
Test invalid bindto
|
||||
--FILE--
|
||||
<?php
|
||||
$ctx = stream_context_create([
|
||||
'socket' => [
|
||||
'bindto' => 'invalid',
|
||||
],
|
||||
]);
|
||||
$fp = stream_socket_client(
|
||||
'tcp://www.' . str_repeat('x', 100) . '.com:80',
|
||||
$errno, $errstr, 30, STREAM_CLIENT_CONNECT, $ctx
|
||||
);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: stream_socket_client(): Unable to connect to tcp://%s:80 (Failed to parse address "invalid") in %s on line %d
|
@ -744,6 +744,10 @@ static inline int php_tcp_sockop_connect(php_stream *stream, php_netstream_data_
|
||||
return -1;
|
||||
}
|
||||
bindto = parse_ip_address_ex(Z_STRVAL_P(tmpzval), Z_STRLEN_P(tmpzval), &bindport, xparam->want_errortext, &xparam->outputs.error_text);
|
||||
if (bindto == NULL) {
|
||||
efree(host);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SO_BROADCAST
|
||||
|
Loading…
Reference in New Issue
Block a user