From 3377cc74dffddcca25eee4256dd3d5635fdac6ba Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 5 Aug 2021 23:46:15 +0200 Subject: [PATCH] Kernel: Use try_copy_kstring_from_user() in sys$mount() --- Kernel/Syscalls/mount.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Kernel/Syscalls/mount.cpp b/Kernel/Syscalls/mount.cpp index f9444595e8..5bfcb5fec3 100644 --- a/Kernel/Syscalls/mount.cpp +++ b/Kernel/Syscalls/mount.cpp @@ -30,12 +30,15 @@ KResultOr Process::sys$mount(Userspace return EFAULT; auto source_fd = params.source_fd; - auto target = copy_string_from_user(params.target); - if (target.is_null()) - return EFAULT; - auto fs_type = copy_string_from_user(params.fs_type); - if (fs_type.is_null()) - return EFAULT; + auto target_or_error = try_copy_kstring_from_user(params.target); + if (target_or_error.is_error()) + return target_or_error.error(); + auto fs_type_or_error = try_copy_kstring_from_user(params.fs_type); + if (fs_type_or_error.is_error()) + return fs_type_or_error.error(); + + auto target = target_or_error.value()->view(); + auto fs_type = fs_type_or_error.value()->view(); auto description = fds().file_description(source_fd); if (!description.is_null())