1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix GH-18617: socket_import_file_descriptor return check.

to_zval_read_fd_array() helper when retrieving the socket protocol did
not check it.

close GH-18617
This commit is contained in:
David Carlier
2025-05-21 19:26:15 +01:00
parent 910aeaafc1
commit c30bddc18f
2 changed files with 9 additions and 1 deletions

4
NEWS
View File

@@ -47,6 +47,10 @@ PHP NEWS
- PDO_OCI:
. Fixed bug GH-18494 (PDO OCI segfault in statement GC). (nielsdos)
- Sockets:
- Fixed bug GH-18617 (socket_import_file_descriptor return value
unchecked). (David Carlier)
- SPL:
. Fixed bug GH-18421 (Integer overflow with large numbers in LimitIterator).
(nielsdos)

View File

@@ -1457,7 +1457,11 @@ void to_zval_read_fd_array(const char *data, zval *zv, res_context *ctx)
object_init_ex(&elem, socket_ce);
php_socket *sock = Z_SOCKET_P(&elem);
socket_import_file_descriptor(fd, sock);
if (!socket_import_file_descriptor(fd, sock)) {
do_to_zval_err(ctx, "error getting protocol descriptor %d: getsockopt() call failed with errno %d", fd, errno);
zval_ptr_dtor(&elem);
return;
}
} else {
php_stream *stream = php_stream_fopen_from_fd(fd, "rw", NULL);
php_stream_to_zval(stream, &elem);