mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
Kernel: Harden sys$setgroups Vector usage against OOM
This commit is contained in:
parent
f0568bff9b
commit
a678851b41
Notes:
sideshowbarker
2024-07-18 18:50:13 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/a678851b41b Pull-request: https://github.com/SerenityOS/serenity/pull/6756 Reviewed-by: https://github.com/awesomekling
1 changed files with 4 additions and 2 deletions
|
@ -163,7 +163,8 @@ KResultOr<int> Process::sys$setgroups(ssize_t count, Userspace<const gid_t*> use
|
|||
}
|
||||
|
||||
Vector<gid_t> new_extra_gids;
|
||||
new_extra_gids.resize(count);
|
||||
if (!new_extra_gids.try_resize(count))
|
||||
return ENOMEM;
|
||||
if (!copy_n_from_user(new_extra_gids.data(), user_gids, count))
|
||||
return EFAULT;
|
||||
|
||||
|
@ -174,7 +175,8 @@ KResultOr<int> Process::sys$setgroups(ssize_t count, Userspace<const gid_t*> use
|
|||
}
|
||||
|
||||
ProtectedDataMutationScope scope { *this };
|
||||
m_extra_gids.resize(unique_extra_gids.size());
|
||||
if (!m_extra_gids.try_resize(unique_extra_gids.size()))
|
||||
return ENOMEM;
|
||||
size_t i = 0;
|
||||
for (auto& extra_gid : unique_extra_gids) {
|
||||
if (extra_gid == gid())
|
||||
|
|
Loading…
Reference in a new issue