From a1a82c1d95ef8e5932f439483ee11b6a8c424c4c Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 1 Mar 2021 15:04:31 +0100 Subject: [PATCH] Kernel: Use Userspace in sys$get_dir_entries() --- Kernel/Process.h | 2 +- Kernel/Syscalls/get_dir_entries.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Kernel/Process.h b/Kernel/Process.h index 0ec32fc5266..263b099cb2b 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -261,7 +261,7 @@ public: KResultOr sys$purge(int mode); KResultOr sys$select(const Syscall::SC_select_params*); KResultOr sys$poll(Userspace); - KResultOr sys$get_dir_entries(int fd, void*, ssize_t); + KResultOr sys$get_dir_entries(int fd, Userspace, ssize_t); KResultOr sys$getcwd(Userspace, size_t); KResultOr sys$chdir(Userspace, size_t); KResultOr sys$fchdir(int fd); diff --git a/Kernel/Syscalls/get_dir_entries.cpp b/Kernel/Syscalls/get_dir_entries.cpp index 627ab8456e5..7065a70870c 100644 --- a/Kernel/Syscalls/get_dir_entries.cpp +++ b/Kernel/Syscalls/get_dir_entries.cpp @@ -29,18 +29,18 @@ namespace Kernel { -KResultOr Process::sys$get_dir_entries(int fd, void* buffer, ssize_t size) +KResultOr Process::sys$get_dir_entries(int fd, Userspace user_buffer, ssize_t user_size) { REQUIRE_PROMISE(stdio); - if (size < 0) + if (user_size < 0) return EINVAL; auto description = file_description(fd); if (!description) return EBADF; - auto user_buffer = UserOrKernelBuffer::for_user_buffer((u8*)buffer, size); - if (!user_buffer.has_value()) + auto buffer = UserOrKernelBuffer::for_user_buffer(user_buffer, static_cast(user_size)); + if (!buffer.has_value()) return EFAULT; - return description->get_dir_entries(user_buffer.value(), size); + return description->get_dir_entries(buffer.value(), user_size); } }