From f85b8406c6be6c8e794248f18a7d3c18fcb03811 Mon Sep 17 00:00:00 2001 From: VHANTOMI Date: Mon, 5 Oct 2026 23:31:11 +0200 Subject: [PATCH] fix(libcglue): reject invalid nfds in select `select()` does not validate `n` before processing the descriptor sets or calling the socket backend. Reject negative values and values greater than `FD_SETSIZE` with `EINVAL`, as required by POSIX. Testing: - Not run locally. - CI checks pending. --- ee/libcglue/src/select.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ee/libcglue/src/select.c b/ee/libcglue/src/select.c index b4f3336eb64c..2aea93ec080d 100644 --- a/ee/libcglue/src/select.c +++ b/ee/libcglue/src/select.c @@ -26,6 +26,12 @@ int select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct t fd_set ready_readfds, ready_writefds, ready_exceptfds; fd_set iop_readfds, iop_writefds, iop_exceptfds; + if (n < 0 || n > FD_SETSIZE) +{ + errno = EINVAL; + return -1; +} + if (_libcglue_fdman_socket_ops == NULL || _libcglue_fdman_socket_ops->select == NULL) { errno = ENOSYS;