diff --git a/Kernel/Process.h b/Kernel/Process.h index 0e64e326cf..dff5e01325 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -294,14 +294,14 @@ public: ErrorOr sys$open(Userspace); ErrorOr sys$close(int fd); ErrorOr sys$read(int fd, Userspace, size_t); - ErrorOr sys$pread(int fd, Userspace, size_t, Userspace); + ErrorOr sys$pread(int fd, Userspace, size_t, Userspace); ErrorOr sys$readv(int fd, Userspace iov, int iov_count); ErrorOr sys$write(int fd, Userspace, size_t); ErrorOr sys$writev(int fd, Userspace iov, int iov_count); ErrorOr sys$fstat(int fd, Userspace); ErrorOr sys$stat(Userspace); ErrorOr sys$lseek(int fd, Userspace, int whence); - ErrorOr sys$ftruncate(int fd, Userspace); + ErrorOr sys$ftruncate(int fd, Userspace); ErrorOr sys$kill(pid_t pid_or_pgid, int sig); [[noreturn]] void sys$exit(int status); ErrorOr sys$sigreturn(RegisterState& registers); diff --git a/Kernel/Syscalls/ftruncate.cpp b/Kernel/Syscalls/ftruncate.cpp index f430d25433..feaf027a99 100644 --- a/Kernel/Syscalls/ftruncate.cpp +++ b/Kernel/Syscalls/ftruncate.cpp @@ -9,12 +9,11 @@ namespace Kernel { -ErrorOr Process::sys$ftruncate(int fd, Userspace userspace_length) +ErrorOr Process::sys$ftruncate(int fd, Userspace userspace_length) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) REQUIRE_PROMISE(stdio); - off_t length; - TRY(copy_from_user(&length, userspace_length)); + auto length = TRY(copy_typed_from_user(userspace_length)); if (length < 0) return EINVAL; auto description = TRY(fds().open_file_description(fd)); diff --git a/Kernel/Syscalls/read.cpp b/Kernel/Syscalls/read.cpp index 190a7fe8c5..2f9e21e98a 100644 --- a/Kernel/Syscalls/read.cpp +++ b/Kernel/Syscalls/read.cpp @@ -86,7 +86,7 @@ ErrorOr Process::sys$read(int fd, Userspace buffer, size_t size) return TRY(description->read(user_buffer, size)); } -ErrorOr Process::sys$pread(int fd, Userspace buffer, size_t size, Userspace userspace_offset) +ErrorOr Process::sys$pread(int fd, Userspace buffer, size_t size, Userspace userspace_offset) { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) REQUIRE_PROMISE(stdio); @@ -94,8 +94,7 @@ ErrorOr Process::sys$pread(int fd, Userspace buffer, size_t size, return 0; if (size > NumericLimits::max()) return EINVAL; - off_t offset; - TRY(copy_from_user(&offset, userspace_offset)); + auto offset = TRY(copy_typed_from_user(userspace_offset)); if (offset < 0) return EINVAL; dbgln_if(IO_DEBUG, "sys$pread({}, {}, {}, {})", fd, buffer.ptr(), size, offset);