From 0cc0c3d5032208cac84decb3e861c2cdd19a5aeb Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Wed, 19 May 2021 18:44:52 +0900 Subject: [PATCH] fs/vfs: Fix bug that select() did not return Fix bug that select() did not return when the nfds argument was set to a negative value. The specification is that -1 is set to the return value and EINVAL is set to errno. --- fs/vfs/fs_select.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/vfs/fs_select.c b/fs/vfs/fs_select.c index 5384f7f78d..1a3734aeff 100644 --- a/fs/vfs/fs_select.c +++ b/fs/vfs/fs_select.c @@ -90,6 +90,12 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds, enter_cancellation_point(); + if (nfds < 0) + { + errcode = EINVAL; + goto errout; + } + /* How many pollfd structures do we need to allocate? */ /* Initialize the descriptor list for poll() */