From 34f8147385fe407bd1342f4898bf21d74972f12e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Thu, 4 May 2023 22:17:14 +0200 Subject: [PATCH] sed: Correctly unveil all paths - The veil was never closed. - unveil() only works with absolute paths. - Files from the regular input list weren't unveiled. --- Userland/Utilities/sed.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Userland/Utilities/sed.cpp b/Userland/Utilities/sed.cpp index 30a0df63773..3c37677263c 100644 --- a/Userland/Utilities/sed.cpp +++ b/Userland/Utilities/sed.cpp @@ -877,10 +877,10 @@ ErrorOr serenity_main(Main::Arguments args) } for (auto const& input_filename : TRY(script.input_filenames())) { - TRY(Core::System::unveil(input_filename, "r"sv)); + TRY(Core::System::unveil(TRY(FileSystem::absolute_path(input_filename)), "r"sv)); } for (auto const& output_filename : TRY(script.output_filenames())) { - TRY(Core::System::unveil(output_filename, "w"sv)); + TRY(Core::System::unveil(TRY(FileSystem::absolute_path(output_filename)), "w"sv)); } Vector inputs; @@ -888,10 +888,13 @@ ErrorOr serenity_main(Main::Arguments args) if (filename == "-"sv) { inputs.empend(TRY(InputFile::create_from_stdin())); } else { + TRY(Core::System::unveil(TRY(FileSystem::absolute_path(filename)), edit_in_place ? "rwc"sv : "r"sv)); auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Read)); inputs.empend(TRY(InputFile::create(move(file)))); } } + TRY(Core::System::unveil(nullptr, nullptr)); + if (inputs.is_empty()) { inputs.empend(TRY(InputFile::create_from_stdin())); }