From 4d3d2c85885f4f8542d9eb15ecd31d17a2c98f01 Mon Sep 17 00:00:00 2001 From: Zoraaver Singh Date: Thu, 21 Sep 2023 14:49:08 +0100 Subject: [PATCH] Remove provision of unnecessary fd rights The WASI docs allow for fewer rights to be applied to an fd than requested but not more. This behaviour 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 c096511c95..bb6d67a621 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);