Jelajahi Sumber

Kernel: Properly define `IOV_MAX`

Tim Schumacher 3 tahun lalu
induk
melakukan
098af0f846
3 mengubah file dengan 5 tambahan dan 4 penghapusan
  1. 3 0
      Kernel/API/POSIX/sys/uio.h
  2. 1 2
      Kernel/Syscalls/read.cpp
  3. 1 2
      Kernel/Syscalls/write.cpp

+ 3 - 0
Kernel/API/POSIX/sys/uio.h

@@ -12,6 +12,9 @@
 extern "C" {
 #endif
 
+// Arbitrary pain threshold.
+#define IOV_MAX 1024
+
 struct iovec {
     void* iov_base;
     size_t iov_len;

+ 1 - 2
Kernel/Syscalls/read.cpp

@@ -45,8 +45,7 @@ ErrorOr<FlatPtr> Process::sys$readv(int fd, Userspace<const struct iovec*> iov,
     if (iov_count < 0)
         return EINVAL;
 
-    // Arbitrary pain threshold.
-    if (iov_count > (int)MiB)
+    if (iov_count > IOV_MAX)
         return EFAULT;
 
     u64 total_length = 0;

+ 1 - 2
Kernel/Syscalls/write.cpp

@@ -18,8 +18,7 @@ ErrorOr<FlatPtr> Process::sys$writev(int fd, Userspace<const struct iovec*> iov,
     if (iov_count < 0)
         return EINVAL;
 
-    // Arbitrary pain threshold.
-    if (iov_count > (int)MiB)
+    if (iov_count > IOV_MAX)
         return EFAULT;
 
     u64 total_length = 0;