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)