mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
ext/sockets: drop convert_to_array for multicast leave group settings.
close GH-17371
This commit is contained in:
parent
5ba299be18
commit
9f87a19de4
4 changed files with 62 additions and 5 deletions
3
NEWS
3
NEWS
|
@ -94,6 +94,9 @@ PHP NEWS
|
|||
overflows. (David Carlier)
|
||||
. socket_addrinfo_lookup throws an exception if one or more hints entries
|
||||
has an index as numeric. (David Carlier)
|
||||
. socket_set_option with the options MCAST_LEAVE_GROUP/MCAST_LEAVE_SOURCE_GROUP
|
||||
will throw an exception if its value is not a valid array/object.
|
||||
(David Carlier)
|
||||
|
||||
- Standard:
|
||||
. Fixed crypt() tests on musl when using --with-external-libcrypt
|
||||
|
|
|
@ -131,6 +131,9 @@ PHP 8.5 UPGRADE NOTES
|
|||
. socket_addrinfo_lookup throw a TypeError if any of the hints
|
||||
values cannot be cast to a int and can throw a ValueError if
|
||||
any of these values overflow.
|
||||
. socket_set_option with MCAST_LEAVE_GROUP/MCAST_LEAVE_SOURCE_GROUP
|
||||
options will throw an exception if the value isn't a valid object
|
||||
or array.
|
||||
|
||||
- Zlib:
|
||||
. The "use_include_path" argument for the
|
||||
|
|
|
@ -159,8 +159,16 @@ mcast_req_fun: ;
|
|||
php_sockaddr_storage group = {0};
|
||||
socklen_t glen;
|
||||
|
||||
convert_to_array(arg4);
|
||||
if (Z_TYPE_P(arg4) != IS_ARRAY) {
|
||||
if (UNEXPECTED(Z_TYPE_P(arg4) != IS_OBJECT)) {
|
||||
zend_argument_type_error(4, "must be of type array when argument #3 ($option) is MCAST_LEAVE_GROUP, %s given", zend_zval_value_name(arg4));
|
||||
return FAILURE;
|
||||
} else {
|
||||
opt_ht = Z_OBJPROP_P(arg4);
|
||||
}
|
||||
} else {
|
||||
opt_ht = Z_ARRVAL_P(arg4);
|
||||
}
|
||||
|
||||
if (php_get_address_from_array(opt_ht, "group", php_sock, &group,
|
||||
&glen) == FAILURE) {
|
||||
|
@ -194,9 +202,16 @@ mcast_req_fun: ;
|
|||
source = {0};
|
||||
socklen_t glen,
|
||||
slen;
|
||||
|
||||
convert_to_array(arg4);
|
||||
if (Z_TYPE_P(arg4) != IS_ARRAY) {
|
||||
if (UNEXPECTED(Z_TYPE_P(arg4) != IS_OBJECT)) {
|
||||
zend_argument_type_error(4, "must be of type array when argument #3 ($option) is MCAST_LEAVE_SOURCE_GROUP, %s given", zend_zval_value_name(arg4));
|
||||
return FAILURE;
|
||||
} else {
|
||||
opt_ht = Z_OBJPROP_P(arg4);
|
||||
}
|
||||
} else {
|
||||
opt_ht = Z_ARRVAL_P(arg4);
|
||||
}
|
||||
|
||||
if (php_get_address_from_array(opt_ht, "group", php_sock, &group,
|
||||
&glen) == FAILURE) {
|
||||
|
|
36
ext/sockets/tests/socket_set_option_mcast_error.phpt
Normal file
36
ext/sockets/tests/socket_set_option_mcast_error.phpt
Normal file
|
@ -0,0 +1,36 @@
|
|||
--TEST--
|
||||
Multicast error
|
||||
--EXTENSIONS--
|
||||
sockets
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (PHP_OS == 'Darwin') die('skip Not for macOS');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
include __DIR__."/mcast_helpers.php.inc";
|
||||
$domain = AF_INET;
|
||||
$level = IPPROTO_IP;
|
||||
$interface = "lo";
|
||||
$mcastaddr = '224.0.0.23';
|
||||
$sblock = "127.0.0.1";
|
||||
|
||||
$s = socket_create($domain, SOCK_DGRAM, SOL_UDP);
|
||||
$b = socket_bind($s, '0.0.0.0', 0);
|
||||
$iwanttoleavenow = true;
|
||||
|
||||
try {
|
||||
socket_set_option($s, $level, MCAST_LEAVE_GROUP, $iwanttoleavenow);
|
||||
} catch (\TypeError $e) {
|
||||
echo $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
socket_set_option($s, $level, MCAST_LEAVE_SOURCE_GROUP, $iwanttoleavenow);
|
||||
} catch (\TypeError $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
socket_set_option(): Argument #4 ($value) must be of type array when argument #3 ($option) is MCAST_LEAVE_GROUP, true given
|
||||
socket_set_option(): Argument #4 ($value) must be of type array when argument #3 ($option) is MCAST_LEAVE_SOURCE_GROUP, true given
|
Loading…
Add table
Add a link
Reference in a new issue