mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
Kernel: Harden sys$readv / sys$writev Vector usage against OOM.
This commit is contained in:
parent
cd29eb7867
commit
454d2fd42a
2 changed files with 4 additions and 2 deletions
|
@ -24,7 +24,8 @@ KResultOr<ssize_t> Process::sys$readv(int fd, Userspace<const struct iovec*> iov
|
|||
|
||||
u64 total_length = 0;
|
||||
Vector<iovec, 32> vecs;
|
||||
vecs.resize(iov_count);
|
||||
if (!vecs.try_resize(iov_count))
|
||||
return ENOMEM;
|
||||
if (!copy_n_from_user(vecs.data(), iov, iov_count))
|
||||
return EFAULT;
|
||||
for (auto& vec : vecs) {
|
||||
|
|
|
@ -23,7 +23,8 @@ KResultOr<ssize_t> Process::sys$writev(int fd, Userspace<const struct iovec*> io
|
|||
|
||||
u64 total_length = 0;
|
||||
Vector<iovec, 32> vecs;
|
||||
vecs.resize(iov_count);
|
||||
if (!vecs.try_resize(iov_count))
|
||||
return ENOMEM;
|
||||
if (!copy_n_from_user(vecs.data(), iov, iov_count))
|
||||
return EFAULT;
|
||||
for (auto& vec : vecs) {
|
||||
|
|
Loading…
Add table
Reference in a new issue