Skip to content

Commit

Permalink
Fixes incorrect guest fd encoding
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jakub Konka authored and sunfishcode committed Jun 19, 2019
1 parent 8dc1d90 commit 7ac6666
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions wasmtime-wasi-c/src/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 7ac6666

Please sign in to comment.