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
Notes:
sideshowbarker
2024-07-18 18:53:52 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/a8765fa6737 Pull-request: https://github.com/SerenityOS/serenity/pull/6733
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);
|
||||
return EBADF;
|
||||
}
|
||||
fds_info.append({ description.release_nonnull(), block_flags });
|
||||
fds.append(fd);
|
||||
if (!fds_info.try_append({ description.release_nonnull(), block_flags }))
|
||||
return ENOMEM;
|
||||
if (!fds.try_append(fd))
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
if constexpr (IO_DEBUG || POLL_SELECT_DEBUG)
|
||||
|
|
Loading…
Add table
Reference in a new issue