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 #2620.
  • Loading branch information
peterhuene committed Jan 28, 2021
1 parent 6079d72 commit 9ff8101
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/test-programs/wasi-tests/src/bin/fd_readdir.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use more_asserts::assert_gt;
use std::{cmp::min, env, mem, process, slice, str};
use std::{env, mem, process, slice, str};
use wasi_tests::open_scratch_directory;

const BUF_LEN: usize = 256;
Expand Down 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 9ff8101

Please sign in to comment.