diff options
author | Andreas Kling <kling@serenityos.org> | 2021-08-05 23:13:39 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-06 00:37:47 +0200 |
commit | 95669fa8611770d993cc36268300473884615144 (patch) | |
tree | 4870a0d2a0171ebe91b85cd4f7e7080704dddf31 /Kernel/Syscalls/link.cpp | |
parent | 5b13af0edd3622d65f4adca93ec822f19ca75edc (diff) | |
download | serenity-95669fa8611770d993cc36268300473884615144.zip |
Kernel: Use try_copy_kstring_from_user() in sys$link()
Diffstat (limited to 'Kernel/Syscalls/link.cpp')
-rw-r--r-- | Kernel/Syscalls/link.cpp | 14 |
1 files 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<FlatPtr> Process::sys$link(Userspace<const Syscall::SC_link_params*> 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<FlatPtr> Process::sys$symlink(Userspace<const Syscall::SC_symlink_params*> user_params) |