1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-25 22:15:06 +00:00

Kernel: Harden Process Vector usage against OOM.

This commit is contained in:
Brian Gianforcaro 2021-04-30 03:18:10 -07:00 committed by Linus Groh
parent ee84b8a845
commit 2ee1731966

View file

@ -146,7 +146,10 @@ RefPtr<Process> Process::create_user_process(RefPtr<Thread>& first_thread, const
auto process = adopt_ref(*new Process(first_thread, parts.take_last(), uid, gid, parent_pid, false, move(cwd), nullptr, tty));
if (!first_thread)
return {};
process->m_fds.resize(m_max_open_file_descriptors);
if (!process->m_fds.try_resize(m_max_open_file_descriptors)) {
first_thread = nullptr;
return {};
}
auto& device_to_use_as_tty = tty ? (CharacterDevice&)*tty : NullDevice::the();
auto description = device_to_use_as_tty.open(O_RDWR).value();
process->m_fds[0].set(*description);