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

Function fresh_ctx

src/runtime.rs:26–63  ·  view source on GitHub ↗
(homedir: String)

Source from the content-addressed store, hash-verified

24#[external_methods(init_std_fds, unwrap, as_raw_fd, create, to_owned, clone)]
25#[external_calls(open, forget, get_homedir_fd, from)]
26pub fn fresh_ctx(homedir: String) -> VmCtx {
27 let memlen = LINEAR_MEM_SIZE;
28 let mem = vec![0; memlen];
29 let mut fdmap = FdMap::new();
30 fdmap.init_std_fds();
31 let homedir_host_fd = get_homedir_fd(&homedir) as usize;
32 // let homedir_file = std::fs::File::open(&homedir).unwrap();
33 // let homedir_fd = homedir_file.as_raw_fd();
34 if homedir_host_fd >= 0 {
35 fdmap.create(HostFd::from_raw(homedir_host_fd));
36 }
37 // Need to forget file to make sure it does not get auto-closed
38 // when it gets out of scope
39 // std::mem::forget(homedir_file);
40 // let log_path = "".to_owned();
41 // let log_path = String::new();
42
43 let arg_buffer = Vec::new();
44 let argc = 0;
45 let env_buffer = Vec::new();
46 let envc = 0;
47
48 let netlist = empty_netlist();
49 VmCtx {
50 mem,
51 memlen,
52 fdmap,
53 homedir,
54 homedir_host_fd: HostFd::from_raw(homedir_host_fd),
55 // errno: Success,
56 arg_buffer,
57 argc,
58 env_buffer,
59 envc,
60 // log_path,
61 netlist,
62 }
63}
64
65impl VmCtx {
66 /// Check whether sandbox pointer is actually inside the sandbox

Callers 6

check_memcpy_to_sandboxFunction · 0.85
check_slice_mem_mutFunction · 0.85
check_resolve_pathFunction · 0.85
trial_1_safeFunction · 0.85
trial_1_unsafeFunction · 0.85

Calls 4

get_homedir_fdFunction · 0.85
empty_netlistFunction · 0.85
init_std_fdsMethod · 0.80
createMethod · 0.80

Tested by 2

trial_1_safeFunction · 0.68
trial_1_unsafeFunction · 0.68