From 2ed4e473009538b2c1c15b6ac2a90576a7fd39d5 Mon Sep 17 00:00:00 2001 From: David Lindbom Date: Mon, 17 Jan 2022 22:26:48 +0100 Subject: [PATCH] zip: Add unveil and pledge promises --- Userland/Utilities/zip.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Userland/Utilities/zip.cpp b/Userland/Utilities/zip.cpp index 6dce8adc18..d8d4dbd7fd 100644 --- a/Userland/Utilities/zip.cpp +++ b/Userland/Utilities/zip.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include ErrorOr serenity_main(Main::Arguments arguments) @@ -27,6 +28,15 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_option(force, "Overwrite existing zip file", "force", 'f'); args_parser.parse(arguments); + TRY(Core::System::pledge("stdio rpath wpath cpath")); + + auto cwd = TRY(Core::System::getcwd()); + TRY(Core::System::unveil(LexicalPath::absolute_path(cwd, zip_path), "wc")); + for (auto const& source_path : source_paths) { + TRY(Core::System::unveil(LexicalPath::absolute_path(cwd, source_path), "r")); + } + TRY(Core::System::unveil(nullptr, nullptr)); + String zip_file_path { zip_path }; if (Core::File::exists(zip_file_path)) { if (force) {