mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
Kernel: writev() should fail with EINVAL if total length > INT32_MAX
This commit is contained in:
parent
7f04334664
commit
c01f766fb2
1 changed files with 7 additions and 1 deletions
|
@ -40,6 +40,7 @@
|
||||||
#include <Kernel/VM/InodeVMObject.h>
|
#include <Kernel/VM/InodeVMObject.h>
|
||||||
#include <Kernel/VM/PurgeableVMObject.h>
|
#include <Kernel/VM/PurgeableVMObject.h>
|
||||||
#include <LibC/errno_numbers.h>
|
#include <LibC/errno_numbers.h>
|
||||||
|
#include <LibC/limits.h>
|
||||||
#include <LibC/signal_numbers.h>
|
#include <LibC/signal_numbers.h>
|
||||||
#include <LibELF/ELFLoader.h>
|
#include <LibELF/ELFLoader.h>
|
||||||
#include <LibELF/exec_elf.h>
|
#include <LibELF/exec_elf.h>
|
||||||
|
@ -1272,7 +1273,12 @@ ssize_t Process::sys$writev(int fd, const struct iovec* iov, int iov_count)
|
||||||
if (!validate_read_typed(iov, iov_count))
|
if (!validate_read_typed(iov, iov_count))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
// FIXME: Return EINVAL if sum of iovecs is greater than INT_MAX
|
u64 total_length = 0;
|
||||||
|
for (int i = 0; i < iov_count; ++i) {
|
||||||
|
total_length += iov[i].iov_len;
|
||||||
|
if (total_length > INT32_MAX)
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
auto* description = file_description(fd);
|
auto* description = file_description(fd);
|
||||||
if (!description)
|
if (!description)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue