From 9d41dd2ed03e41d9decb5f3c0298227a0c76a882 Mon Sep 17 00:00:00 2001 From: Max Wipfli Date: Sun, 6 Jun 2021 19:19:59 +0200 Subject: [PATCH] Kernel: Use LexicalPath to avoid two consecutive slashes in unveil path This patch fixes a bug in the unveil syscall where an UnveilNode's path would start with two slashes if it's parent node was "/". --- Kernel/Syscalls/unveil.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Kernel/Syscalls/unveil.cpp b/Kernel/Syscalls/unveil.cpp index 9e4257964c..0d4d8d9b99 100644 --- a/Kernel/Syscalls/unveil.cpp +++ b/Kernel/Syscalls/unveil.cpp @@ -105,7 +105,10 @@ KResultOr Process::sys$unveil(Userspace u it, lexical_path.parts().end(), { new_unveiled_path, (UnveilAccess)new_permissions, true }, - [](auto& parent, auto& it) -> Optional { return UnveilMetadata { String::formatted("{}/{}", parent.path(), *it), parent.permissions(), false, parent.permissions_inherited_from_root() }; }); + [](auto& parent, auto& it) -> Optional { + auto path = LexicalPath::join(parent.path(), *it).string(); + return UnveilMetadata { path, parent.permissions(), false, parent.permissions_inherited_from_root() }; + }); VERIFY(m_veil_state != VeilState::Locked); m_veil_state = VeilState::Dropped; return 0;