Kernel: Use try_copy_kstring_from_user() in sys$link()

This commit is contained in:
Andreas Kling 2021-08-05 23:13:39 +02:00
parent 5b13af0edd
commit 95669fa861

View file

@ -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(&params, 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)