From 7ac6666fcbe3b05c19a6c87975a00f3ad2a89d33 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Sun, 9 Jun 2019 12:56:54 +0200 Subject: [PATCH] Fixes incorrect guest fd encoding Surfaced when running sunfishcode/misc-tests. When trying to truncate the file without the __WASI_RIGHT_PATH_FILESTAT_SET_SIZE right, error __WASI_ENOTCAPABLE was correctly returned, however, the guest fd pointer was not encoded to -1 in that case. This commit fixes it by taking out the guest fd encoding out of the conditional branch which turns out obsolete. --- wasmtime-wasi-c/src/syscalls.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/wasmtime-wasi-c/src/syscalls.rs b/wasmtime-wasi-c/src/syscalls.rs index ab2642fcca..66743c05e9 100644 --- a/wasmtime-wasi-c/src/syscalls.rs +++ b/wasmtime-wasi-c/src/syscalls.rs @@ -956,10 +956,8 @@ syscalls! { &mut host_fd, ); - if u32::from(e) == host::__WASI_ESUCCESS { - trace!(" | *fd={:?}", host_fd); - encode_fd_byref(vmctx, fd, host_fd); - } + trace!(" | *fd={:?}", host_fd); + encode_fd_byref(vmctx, fd, host_fd); return_encoded_errno(e) }