diff --git a/NEWS b/NEWS index d35d34b84e9..336de62b6a3 100644 --- a/NEWS +++ b/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). diff --git a/UPGRADING b/UPGRADING index 0847ad009e7..87d08e12601 100644 --- a/UPGRADING +++ b/UPGRADING @@ -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 diff --git a/ext/sockets/sockaddr_conv.c b/ext/sockets/sockaddr_conv.c index 9840a98dbcb..333ef2533a1 100644 --- a/ext/sockets/sockaddr_conv.c +++ b/ext/sockets/sockaddr_conv.c @@ -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; } diff --git a/ext/sockets/tests/mcast_sockettype_error.phpt b/ext/sockets/tests/mcast_sockettype_error.phpt new file mode 100644 index 00000000000..56308534ebc --- /dev/null +++ b/ext/sockets/tests/mcast_sockettype_error.phpt @@ -0,0 +1,30 @@ +--TEST-- +Multicast attempt on unsupported socket type +--EXTENSIONS-- +sockets +--SKIPIF-- + +--FILE-- + '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