Kernel: Make sure to clear FD sets when preparing for a select

NULL sets can happen, and we don't want to incorrectly return FDs which
aren't in the set too.
This commit is contained in:
Robin Burchell 2019-05-18 02:00:54 +02:00 committed by Andreas Kling
parent 95893b0d53
commit ba92c07a75
Notes: sideshowbarker 2024-07-19 14:02:40 +09:00

View file

@ -1751,9 +1751,9 @@ int Process::sys$select(const Syscall::SC_select_params* params)
// FIXME: Return -EINVAL if timeout is invalid.
auto transfer_fds = [this, nfds] (fd_set* set, auto& vector) -> int {
vector.clear_with_capacity();
if (!set)
return 0;
vector.clear_with_capacity();
auto bitmap = Bitmap::wrap((byte*)set, FD_SETSIZE);
for (int i = 0; i < nfds; ++i) {
if (bitmap.get(i)) {