Skip to content

Commit

Permalink
Fix invalid access to wasi instance handles
Browse files Browse the repository at this point in the history
  • Loading branch information
g-bartoszek authored and theduke committed Aug 31, 2023
1 parent c123a5a commit 240157c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/wasix/src/state/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,12 @@ impl WasiEnv {
(memory, state, inodes)
}

pub(crate) fn get_wasi_state_and_inodes(&self) -> (&WasiState, &WasiInodes) {
let state = self.state.deref();
let inodes = &state.inodes;
(state, inodes)
}

/// Make all the commands in a [`BinaryPackage`] available to the WASI
/// instance.
///
Expand Down
3 changes: 1 addition & 2 deletions lib/wasix/src/syscalls/wasix/proc_spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ pub fn proc_spawn_internal(

// Replace the STDIO
let (stdin, stdout, stderr) = {
let (_, child_state, child_inodes) =
unsafe { child_env.get_memory_and_wasi_state_and_inodes(&new_store, 0) };
let (child_state, child_inodes) = child_env.get_wasi_state_and_inodes();
let mut conv_stdio_mode = |mode: WasiStdioMode, fd: WasiFd| -> Result<OptionFd, Errno> {
match mode {
WasiStdioMode::Piped => {
Expand Down

0 comments on commit 240157c

Please sign in to comment.