diff options
author | Andreas Kling <kling@serenityos.org> | 2021-05-29 16:59:40 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-29 20:18:57 +0200 |
commit | 1123af361dbea6f1c3ae0289aa676233a6e9d75b (patch) | |
tree | 6ea02673365d20eca8d489082f916e30fc023e83 /Kernel/Syscalls/unveil.cpp | |
parent | 66f3ec687b2b562205e91ef587e771aef33fada9 (diff) | |
download | serenity-1123af361dbea6f1c3ae0289aa676233a6e9d75b.zip |
Kernel: Convert Process::get_syscall_path_argument() to KString
This API now returns a KResultOr<NonnullOwnPtr<KString>> and allocation
failures should be propagated everywhere nicely. :^)
Diffstat (limited to 'Kernel/Syscalls/unveil.cpp')
-rw-r--r-- | Kernel/Syscalls/unveil.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Kernel/Syscalls/unveil.cpp b/Kernel/Syscalls/unveil.cpp index 9ccee90315..9e4257964c 100644 --- a/Kernel/Syscalls/unveil.cpp +++ b/Kernel/Syscalls/unveil.cpp @@ -32,11 +32,12 @@ KResultOr<int> Process::sys$unveil(Userspace<const Syscall::SC_unveil_params*> u if (params.permissions.length > 5) return EINVAL; - auto path = get_syscall_path_argument(params.path); - if (path.is_error()) - return path.error(); + auto path_or_error = get_syscall_path_argument(params.path); + if (path_or_error.is_error()) + return path_or_error.error(); + auto& path = *path_or_error.value(); - if (path.value().is_empty() || path.value().characters()[0] != '/') + if (path.is_empty() || !path.view().starts_with('/')) return EINVAL; auto permissions = copy_string_from_user(params.permissions); @@ -74,11 +75,11 @@ KResultOr<int> Process::sys$unveil(Userspace<const Syscall::SC_unveil_params*> u // If this case is encountered, the parent node of the path is returned and the custody of that inode is used instead. RefPtr<Custody> parent_custody; // Parent inode in case of ENOENT String new_unveiled_path; - auto custody_or_error = VFS::the().resolve_path_without_veil(path.value(), root_directory(), &parent_custody); + auto custody_or_error = VFS::the().resolve_path_without_veil(path.view(), root_directory(), &parent_custody); if (!custody_or_error.is_error()) { new_unveiled_path = custody_or_error.value()->absolute_path(); } else if (custody_or_error.error() == -ENOENT && parent_custody && (new_permissions & UnveilAccess::CreateOrRemove)) { - String basename = LexicalPath(path.value()).basename(); + String basename = LexicalPath(path.view()).basename(); new_unveiled_path = String::formatted("{}/{}", parent_custody->absolute_path(), basename); } else { // FIXME Should this be EINVAL? |