MCPcopy Create free account
hub / github.com/PLSysSec/wave / init_std_fds

Method init_std_fds

src/fdmap.rs:43–56  ·  view source on GitHub ↗

should only be called on empty fdmap

(&mut self)

Source from the content-addressed store, hash-verified

41 // #[external_method(into)]
42 #[requires (self.counter == 0)] //should only be called on empty fdmap
43 pub fn init_std_fds(&mut self) -> RuntimeResult<()> {
44 let stdin_fd = stdin().as_raw_fd();
45 let stdout_fd = stdout().as_raw_fd();
46 let stderr_fd = stderr().as_raw_fd();
47 if (stdin_fd >= 0) && (stdout_fd >= 0) && (stderr_fd >= 0) {
48 // upcasting i32 => usize is safe since we checked that it is positive
49 // viper overflow checker would yell at us if this was not the case
50 self.create(HostFd::from_raw(stdin_fd as usize));
51 self.create(HostFd::from_raw(stdout_fd as usize));
52 self.create(HostFd::from_raw(stderr_fd as usize));
53 return Ok(());
54 }
55 Err(Emfile) // File descriptor failure
56 }
57
58 #[pure]
59 #[requires (index < MAX_SBOX_FDS )]

Callers 2

create_ctxFunction · 0.80
fresh_ctxFunction · 0.80

Calls 1

createMethod · 0.80

Tested by

no test coverage detected