1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 00:07:34 +00:00

Kernel: Remove unnecessary TOCTOU bug in sys$pipe()

We don't need to explicitly check for EMFILE conditions before doing
anything in sys$pipe(). The fd allocation code will take care of it
for us anyway.
This commit is contained in:
Andreas Kling 2022-08-16 20:16:17 +02:00
parent 2a386c0b50
commit 0b58fd5aef

View file

@ -13,9 +13,7 @@ ErrorOr<FlatPtr> Process::sys$pipe(int pipefd[2], int flags)
{
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
TRY(require_promise(Pledge::stdio));
auto open_count = fds().with_shared([](auto& fds) { return fds.open_count(); });
if (open_count + 2 > OpenFileDescriptions::max_open())
return EMFILE;
// Reject flags other than O_CLOEXEC, O_NONBLOCK
if ((flags & (O_CLOEXEC | O_NONBLOCK)) != flags)
return EINVAL;