summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Process.h2
-rw-r--r--Kernel/Syscalls/read.cpp4
2 files changed, 4 insertions, 2 deletions
diff --git a/Kernel/Process.h b/Kernel/Process.h
index f212074fc2..64feb852a0 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -294,7 +294,7 @@ public:
ErrorOr<FlatPtr> sys$open(Userspace<const Syscall::SC_open_params*>);
ErrorOr<FlatPtr> sys$close(int fd);
ErrorOr<FlatPtr> sys$read(int fd, Userspace<u8*>, size_t);
- ErrorOr<FlatPtr> sys$pread(int fd, Userspace<u8*>, size_t, off_t);
+ ErrorOr<FlatPtr> sys$pread(int fd, Userspace<u8*>, size_t, Userspace<off_t*>);
ErrorOr<FlatPtr> sys$readv(int fd, Userspace<const struct iovec*> iov, int iov_count);
ErrorOr<FlatPtr> sys$write(int fd, Userspace<const u8*>, size_t);
ErrorOr<FlatPtr> sys$writev(int fd, Userspace<const struct iovec*> iov, int iov_count);
diff --git a/Kernel/Syscalls/read.cpp b/Kernel/Syscalls/read.cpp
index 4dc7b0d15a..a001285925 100644
--- a/Kernel/Syscalls/read.cpp
+++ b/Kernel/Syscalls/read.cpp
@@ -90,7 +90,7 @@ ErrorOr<FlatPtr> Process::sys$read(int fd, Userspace<u8*> buffer, size_t size)
return TRY(description->read(user_buffer.value(), size));
}
-ErrorOr<FlatPtr> Process::sys$pread(int fd, Userspace<u8*> buffer, size_t size, off_t offset)
+ErrorOr<FlatPtr> Process::sys$pread(int fd, Userspace<u8*> buffer, size_t size, Userspace<off_t*> userspace_offset)
{
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
REQUIRE_PROMISE(stdio);
@@ -98,6 +98,8 @@ ErrorOr<FlatPtr> Process::sys$pread(int fd, Userspace<u8*> buffer, size_t size,
return 0;
if (size > NumericLimits<ssize_t>::max())
return EINVAL;
+ off_t offset;
+ TRY(copy_from_user(&offset, userspace_offset));
if (offset < 0)
return EINVAL;
dbgln_if(IO_DEBUG, "sys$pread({}, {}, {}, {})", fd, buffer.ptr(), size, offset);