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

Function parse_iovs

src/iov.rs:92–131  ·  view source on GitHub ↗
(ctx: &VmCtx, iovs: u32, iovcnt: u32)

Source from the content-addressed store, hash-verified

90)]
91#[external_methods(push)]
92pub fn parse_iovs(ctx: &VmCtx, iovs: u32, iovcnt: u32) -> RuntimeResult<WasmIoVecs> {
93 let mut i = 0;
94 let mut wasm_iovs = WasmIoVecs::new();
95 while i < iovcnt {
96 body_invariant!(ctx_safe(ctx));
97 body_invariant!(trace_safe(trace, ctx));
98 body_invariant!(wasm_iovs.len() >= 0);
99 body_invariant!(
100 forall(|idx: usize| (idx < wasm_iovs.len() && idx >= 0) ==> {
101 let iov = wasm_iovs.lookup(idx);
102 let buf = iov.iov_base;
103 let cnt = iov.iov_len;
104 // ctx.fits_in_lin_mem(buf, cnt, trace)
105 (buf >= 0) && (cnt >= 0) &&
106 (buf as usize) + (cnt as usize) < LINEAR_MEM_SIZE &&
107 (buf <= buf + cnt)
108 })
109
110 );
111
112 let start = (iovs + i * 8) as usize;
113 //TODO: Once we fix ? operatior - fix this
114 //let (ptr, len) = ctx.read_u32_pair(start)?;
115 let v = ctx.read_u32_pair(start);
116 unwrap_result!(v);
117 let (ptr, len) = v;
118
119 if !ctx.fits_in_lin_mem(ptr, len) {
120 return Err(Efault);
121 }
122
123 wasm_iovs.push(WasmIoVec {
124 iov_base: ptr,
125 iov_len: len,
126 });
127 i += 1;
128 }
129 assert!(wasm_iovs.len() >= 0);
130 Ok(wasm_iovs)
131}

Callers 4

wasi_fd_readFunction · 0.85
wasi_fd_writeFunction · 0.85
wasi_fd_preadFunction · 0.85
wasi_fd_pwriteFunction · 0.85

Calls 3

read_u32_pairMethod · 0.80
fits_in_lin_memMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected