Skip to content
8 changes: 7 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.5.0alpha2
?? ??? ????, PHP 8.5.0alpha3

- Sockets:
. socket_set_option for multicast context throws a ValueError
when the socket family is not of AF_INET/AF_INET6 family. (David Carlier)

17 Jul 2025, PHP 8.5.0alpha2

- Core:
. Fix OSS-Fuzz #427814452 (pipe compilation fails with assert).
Expand Down
2 changes: 2 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_opcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ static void zend_check_finally_breakout(zend_op_array *op_array, uint32_t op_num
}
}

static uint32_t zend_get_brk_cont_target(const zend_op_array *op_array, const zend_op *opline) {
static uint32_t zend_get_brk_cont_target(const zend_op *opline) {
int nest_levels = opline->op2.num;
int array_offset = opline->op1.num;
zend_brk_cont_element *jmp_to;
Expand Down Expand Up @@ -1120,7 +1120,7 @@ ZEND_API void pass_two(zend_op_array *op_array)
case ZEND_BRK:
case ZEND_CONT:
{
uint32_t jmp_target = zend_get_brk_cont_target(op_array, opline);
uint32_t jmp_target = zend_get_brk_cont_target(opline);

if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) {
zend_check_finally_breakout(op_array, opline - op_array->opcodes, jmp_target);
Expand Down
4 changes: 2 additions & 2 deletions ext/openssl/openssl_backend_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ zend_result php_openssl_load_rand_file(const char * file, int *egdsocket, int *s
return SUCCESS;
#endif
}
if (file == NULL || !RAND_load_file(file, -1)) {
if (file == NULL || RAND_load_file(file, -1) < 0) {
if (RAND_status() == 0) {
php_openssl_store_errors();
php_error_docref(NULL, E_WARNING, "Unable to load random state; not enough random data!");
Expand All @@ -465,7 +465,7 @@ zend_result php_openssl_write_rand_file(const char * file, int egdsocket, int se
if (file == NULL) {
file = RAND_file_name(buffer, sizeof(buffer));
}
if (file == NULL || !RAND_write_file(file)) {
if (file == NULL || RAND_write_file(file) < 0) {
php_openssl_store_errors();
php_error_docref(NULL, E_WARNING, "Unable to write random state");
return FAILURE;
Expand Down
3 changes: 1 addition & 2 deletions ext/sockets/sockaddr_conv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 30 additions & 0 deletions ext/sockets/tests/mcast_sockettype_error.phpt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions ext/xml/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ get_entity(void *user, const xmlChar *name)
if (ret == NULL)
ret = xmlGetDocEntity(parser->parser->myDoc, name);

ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations")
if (ret == NULL || parser->parser->instate == XML_PARSER_CONTENT) {
ZEND_DIAGNOSTIC_IGNORED_END
if (ret == NULL || ret->etype == XML_INTERNAL_GENERAL_ENTITY || ret->etype == XML_INTERNAL_PARAMETER_ENTITY || ret->etype == XML_INTERNAL_PREDEFINED_ENTITY) {
/* Predefined entities will expand unless no cdata handler is present */
if (parser->h_default && ! (ret && ret->etype == XML_INTERNAL_PREDEFINED_ENTITY && parser->h_cdata)) {
Expand Down