From 95669fa8611770d993cc36268300473884615144 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 5 Aug 2021 23:13:39 +0200 Subject: [PATCH] Kernel: Use try_copy_kstring_from_user() in sys$link() --- Kernel/Syscalls/link.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Kernel/Syscalls/link.cpp b/Kernel/Syscalls/link.cpp index be3941e9e3..d0b08125ac 100644 --- a/Kernel/Syscalls/link.cpp +++ b/Kernel/Syscalls/link.cpp @@ -17,13 +17,13 @@ KResultOr Process::sys$link(Userspace u Syscall::SC_link_params params; if (!copy_from_user(¶ms, user_params)) return EFAULT; - auto old_path = copy_string_from_user(params.old_path); - if (old_path.is_null()) - return EFAULT; - auto new_path = copy_string_from_user(params.new_path); - if (new_path.is_null()) - return EFAULT; - return VirtualFileSystem::the().link(old_path, new_path, current_directory()); + auto old_path_or_error = try_copy_kstring_from_user(params.old_path); + if (old_path_or_error.is_error()) + return old_path_or_error.error(); + auto new_path_or_error = try_copy_kstring_from_user(params.new_path); + if (new_path_or_error.is_error()) + return new_path_or_error.error(); + return VirtualFileSystem::the().link(old_path_or_error.value()->view(), new_path_or_error.value()->view(), current_directory()); } KResultOr Process::sys$symlink(Userspace user_params)