mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
ext/sockets: multicast on unsupported socket type error change.
From a mere warning to an exception. close GH-19114
This commit is contained in:
4
NEWS
4
NEWS
@@ -14,6 +14,10 @@ PHP NEWS
|
||||
. Fetch larger block sizes and better handle SQL_NO_TOTAL when calling
|
||||
SQLGetData. (Calvin Buckley, Saki Takamachi)
|
||||
|
||||
- Sockets:
|
||||
. socket_set_option for multicast context throws a ValueError
|
||||
when the socket family is not of AF_INET/AF_INET6 family. (David Carlier)
|
||||
|
||||
- Standard:
|
||||
. Optimized pack(). (nielsdos, divinity76)
|
||||
. Fixed bug GH-19070 (setlocale($type, NULL) should not be deprecated).
|
||||
|
||||
@@ -371,6 +371,8 @@ PHP 8.5 UPGRADE NOTES
|
||||
. socket_create/socket_bind can create AF_PACKET family sockets.
|
||||
. socket_getsockname gets the interface index and its string
|
||||
representation with AF_PACKET socket.
|
||||
. socket_set_option with multicast context throws a ValueError
|
||||
when the created socket is not of AF_INET/AF_INET6 family.
|
||||
|
||||
- Tidy:
|
||||
. tidy::__construct/parseFile/parseString now throws a ValueError
|
||||
|
||||
@@ -137,8 +137,7 @@ int php_set_inet46_addr(php_sockaddr_storage *ss, socklen_t *ss_len, zend_string
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
php_error_docref(NULL, E_WARNING,
|
||||
"IP address used in the context of an unexpected type of socket");
|
||||
zend_value_error("IP address used in the context of an unexpected type of socket");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
30
ext/sockets/tests/mcast_sockettype_error.phpt
Normal file
30
ext/sockets/tests/mcast_sockettype_error.phpt
Normal file
@@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
Multicast attempt on unsupported socket type
|
||||
--EXTENSIONS--
|
||||
sockets
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (substr(PHP_OS, 0, 3) == 'WIN') {
|
||||
die('skip Not for Windows!');
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$sock_path = sprintf("/tmp/%s.sock", uniqid());
|
||||
|
||||
if (file_exists($sock_path))
|
||||
die('Temporary socket already exists.');
|
||||
$sock = socket_create(AF_UNIX, SOCK_DGRAM, 0);
|
||||
socket_bind($sock, $sock_path);
|
||||
|
||||
try {
|
||||
socket_set_option($sock, IPPROTO_IP, MCAST_JOIN_GROUP, array(
|
||||
"group" => '127.0.0.1',
|
||||
"interface" => "lo",
|
||||
));
|
||||
} catch (\ValueError $e) {
|
||||
echo $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
IP address used in the context of an unexpected type of socket
|
||||
Reference in New Issue
Block a user