Skip to content

Commit

Permalink
Stop allowing bufused > BUF_LEN in fd_readdir program.
Browse files Browse the repository at this point in the history
This commit removes what appears to be a workaround to the bug being fixed by
the change in bytecodealliance#2620.
  • Loading branch information
peterhuene committed Jan 28, 2021
1 parent 6079d72 commit ca81d53
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/test-programs/wasi-tests/src/bin/fd_readdir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ unsafe fn exec_fd_readdir(fd: wasi::Fd, cookie: wasi::Dircookie) -> (Vec<DirEntr
let bufused =
wasi::fd_readdir(fd, buf.as_mut_ptr(), BUF_LEN, cookie).expect("failed fd_readdir");

let sl = slice::from_raw_parts(buf.as_ptr(), min(BUF_LEN, bufused));
assert!(bufused <= BUF_LEN);

let sl = slice::from_raw_parts(buf.as_ptr(), bufused);
let dirs: Vec<_> = ReadDir::from_slice(sl).collect();
let eof = bufused < BUF_LEN;
(dirs, eof)
Expand Down

0 comments on commit ca81d53

Please sign in to comment.