summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/readlink.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/Syscalls/readlink.cpp')
-rw-r--r--Kernel/Syscalls/readlink.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/Kernel/Syscalls/readlink.cpp b/Kernel/Syscalls/readlink.cpp
index d2b35733a9..b9da03db87 100644
--- a/Kernel/Syscalls/readlink.cpp
+++ b/Kernel/Syscalls/readlink.cpp
@@ -36,10 +36,7 @@ int Process::sys$readlink(Userspace<const Syscall::SC_readlink_params*> user_par
REQUIRE_PROMISE(rpath);
Syscall::SC_readlink_params params;
- if (!validate_read_and_copy_typed(&params, user_params))
- return -EFAULT;
-
- if (!validate(params.buffer))
+ if (!copy_from_user(&params, user_params))
return -EFAULT;
auto path = get_syscall_path_argument(params.path);
@@ -60,7 +57,8 @@ int Process::sys$readlink(Userspace<const Syscall::SC_readlink_params*> user_par
auto& link_target = contents.value();
auto size_to_copy = min(link_target.size(), params.buffer.size);
- copy_to_user(params.buffer.data, link_target.data(), size_to_copy);
+ if (!copy_to_user(params.buffer.data, link_target.data(), size_to_copy))
+ return -EFAULT;
// Note: we return the whole size here, not the copied size.
return link_target.size();
}