From 538c3083578e292056a74a82a971e48410aa8713 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Fri, 5 May 2023 09:25:58 +0330 Subject: [PATCH] LibWasm: Stop passing a nonzero 'mode' to open(..., O_DIRECTORY) Bionic warns on this, but not passing the mode argument is technically undefined behaviour (depending on the libc implementation of open), as our LibC reads `mode` unconditionally (yolo!), just pass a zero to avoid the UB. --- Userland/Libraries/LibWasm/WASI/Wasi.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibWasm/WASI/Wasi.cpp b/Userland/Libraries/LibWasm/WASI/Wasi.cpp index 911c0823ce..a70a99df46 100644 --- a/Userland/Libraries/LibWasm/WASI/Wasi.cpp +++ b/Userland/Libraries/LibWasm/WASI/Wasi.cpp @@ -520,7 +520,7 @@ ErrorOr> Implementation::impl$path_filestat_get(Configuration& auto& entry = preopened_directories()[descriptor.value()]; dir_fd = entry.opened_fd.value_or_lazy_evaluated([&] { DeprecatedString path = entry.host_path.string(); - return open(path.characters(), O_DIRECTORY, 0755); + return open(path.characters(), O_DIRECTORY, 0); }); entry.opened_fd = dir_fd; }, @@ -583,7 +583,7 @@ ErrorOr> Implementation::impl$path_create_directory(Configuration& auto& entry = preopened_directories()[descriptor.value()]; dir_fd = entry.opened_fd.value_or_lazy_evaluated([&] { DeprecatedString path = entry.host_path.string(); - return open(path.characters(), O_DIRECTORY, 0755); + return open(path.characters(), O_DIRECTORY, 0); }); entry.opened_fd = dir_fd; }, @@ -614,7 +614,7 @@ ErrorOr> Implementation::impl$path_open(Configuration& configuration, auto& entry = preopened_directories()[descriptor.value()]; dir_fd = entry.opened_fd.value_or_lazy_evaluated([&] { DeprecatedString path = entry.host_path.string(); - return open(path.characters(), O_DIRECTORY, 0755); + return open(path.characters(), O_DIRECTORY, 0); }); entry.opened_fd = dir_fd; }, @@ -706,7 +706,7 @@ ErrorOr> Implementation::impl$fd_filestat_get(Configuration&, F auto& entry = preopened_directories()[descriptor.value()]; resolved_fd = entry.opened_fd.value_or_lazy_evaluated([&] { DeprecatedString path = entry.host_path.string(); - return open(path.characters(), O_DIRECTORY, 0755); + return open(path.characters(), O_DIRECTORY, 0); }); entry.opened_fd = resolved_fd; },