mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +00:00
Kernel: Harden sys$select Vector usage against OOM.
Theoretically the append should never fail as we have in-line storage of FD_SETSIZE, which should always be enough. However I'm planning on removing the non-try variants of AK::Vector when compiling in kernel mode in the future, so this will need to go eventually. I suppose it also protects against some unforeseen bug where we we can append more than FD_SETSIZE items.
This commit is contained in:
parent
0ca668f59c
commit
a8765fa673
1 changed files with 4 additions and 2 deletions
|
@ -78,8 +78,10 @@ KResultOr<int> Process::sys$select(Userspace<const Syscall::SC_select_params*> u
|
||||||
dbgln("sys$select: Bad fd number {}", fd);
|
dbgln("sys$select: Bad fd number {}", fd);
|
||||||
return EBADF;
|
return EBADF;
|
||||||
}
|
}
|
||||||
fds_info.append({ description.release_nonnull(), block_flags });
|
if (!fds_info.try_append({ description.release_nonnull(), block_flags }))
|
||||||
fds.append(fd);
|
return ENOMEM;
|
||||||
|
if (!fds.try_append(fd))
|
||||||
|
return ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if constexpr (IO_DEBUG || POLL_SELECT_DEBUG)
|
if constexpr (IO_DEBUG || POLL_SELECT_DEBUG)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue