Skip to content

Commit 9ff8101

Browse files
committed
Stop allowing bufused > BUF_LEN in fd_readdir program.
This commit removes what appears to be a workaround to the bug being fixed by the change in #2620.
1 parent 6079d72 commit 9ff8101

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

crates/test-programs/wasi-tests/src/bin/fd_readdir.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use more_asserts::assert_gt;
2-
use std::{cmp::min, env, mem, process, slice, str};
2+
use std::{env, mem, process, slice, str};
33
use wasi_tests::open_scratch_directory;
44

55
const BUF_LEN: usize = 256;
@@ -59,7 +59,9 @@ unsafe fn exec_fd_readdir(fd: wasi::Fd, cookie: wasi::Dircookie) -> (Vec<DirEntr
5959
let bufused =
6060
wasi::fd_readdir(fd, buf.as_mut_ptr(), BUF_LEN, cookie).expect("failed fd_readdir");
6161

62-
let sl = slice::from_raw_parts(buf.as_ptr(), min(BUF_LEN, bufused));
62+
assert!(bufused <= BUF_LEN);
63+
64+
let sl = slice::from_raw_parts(buf.as_ptr(), bufused);
6365
let dirs: Vec<_> = ReadDir::from_slice(sl).collect();
6466
let eof = bufused < BUF_LEN;
6567
(dirs, eof)

0 commit comments

Comments
 (0)