From 06527f724e8b0bc79cdf8e73f78749e4caa9490f Mon Sep 17 00:00:00 2001 From: zoraaver <55952569+zoraaver@users.noreply.github.com> Date: Fri, 22 Sep 2023 02:11:25 +0100 Subject: [PATCH] Remove provision of unnecessary fd rights (#2579) The WASI docs allow for fewer rights to be applied to an fd than requested but not more. This behavior is also asserted in the rust WASI tests, so it's necessary for those to pass as well. --- .../sandboxed-system-primitives/src/posix.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c b/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c index c096511c..bb6d67a6 100644 --- a/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c +++ b/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c @@ -1981,20 +1981,6 @@ wasmtime_ssp_path_open(wasm_exec_env_t exec_env, struct fd_table *curfds, return error; } - { - struct stat sb; - - if (fstat(nfd, &sb) < 0) { - close(nfd); - return convert_errno(errno); - } - - if (S_ISDIR(sb.st_mode)) - rights_base |= (__wasi_rights_t)RIGHTS_DIRECTORY_BASE; - else if (S_ISREG(sb.st_mode)) - rights_base |= (__wasi_rights_t)RIGHTS_REGULAR_FILE_BASE; - } - return fd_table_insert_fd(exec_env, curfds, nfd, type, rights_base & max_base, rights_inheriting & max_inheriting, fd);