Skip to content

Commit

Permalink
fix: cannot read multiple iovecs
Browse files Browse the repository at this point in the history
  • Loading branch information
skanehira committed Jul 21, 2023
1 parent 210b0a1 commit 5b29a49
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/wasi/wasi_snapshot_preview1/preview1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl WasiSnapshotPreview1 {

fn fd_write(&self, store: Rc<RefCell<Store>>, args: Vec<Value>) -> Result<Option<Value>> {
let args: Vec<i32> = args.into_iter().map(Into::into).collect();
let (fd, iovs, iovs_len, rp) = (
let (fd, mut iovs, iovs_len, rp) = (
args[0] as usize,
args[1] as usize,
args[2] as usize,
Expand All @@ -147,14 +147,16 @@ impl WasiSnapshotPreview1 {
offset: iovs as u32,
},
)?;
iovs += 4;

let len: i32 = memory.load(
0,
&MemoryArg {
align: 4,
offset: iovs as u32 + 4,
offset: iovs as u32,
},
)?;
iovs += 4;

let offset = offset as usize;
let end = offset + len as usize;
Expand Down

0 comments on commit 5b29a49

Please sign in to comment.