From 79884f91186a746abe14432e3e92f5401635d7b0 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 13 Jul 2025 07:01:44 +0100 Subject: [PATCH] ext/sockets: multicast on unsupported socket type error change. From a mere warning to an exception. --- ext/sockets/sockaddr_conv.c | 3 +- ext/sockets/tests/mcast_sockettype_error.phpt | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 ext/sockets/tests/mcast_sockettype_error.phpt diff --git a/ext/sockets/sockaddr_conv.c b/ext/sockets/sockaddr_conv.c index 9840a98dbcb72..333ef2533a11b 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 0000000000000..56308534ebc4d --- /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