(ctx: &VmCtx, iovs: u32, iovcnt: u32)
| 90 | )] |
| 91 | #[external_methods(push)] |
| 92 | pub 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 | } |
no test coverage detected