diff --git a/lib/wasi/src/state/mod.rs b/lib/wasi/src/state/mod.rs index 58f94dcd83a..e6e46395a40 100644 --- a/lib/wasi/src/state/mod.rs +++ b/lib/wasi/src/state/mod.rs @@ -1389,7 +1389,7 @@ impl WasiFs { pr_type: Preopentype::Dir, u: PrestatEnum::Dir { // REVIEW: - pr_name_len: inode_val.name.len() as u32 + 1, + pr_name_len: inode_val.name.len() as u32, // no need for +1, because there is no 0 end-of-string marker } .untagged(), } diff --git a/lib/wasi/src/syscalls/mod.rs b/lib/wasi/src/syscalls/mod.rs index 202fb0b2048..50e69877c17 100644 --- a/lib/wasi/src/syscalls/mod.rs +++ b/lib/wasi/src/syscalls/mod.rs @@ -969,13 +969,11 @@ pub fn fd_prestat_dir_name( let deref = guard.deref(); match deref { Kind::Dir { .. } | Kind::Root { .. } => { - // TODO: verify this: null termination, etc let path_len: u64 = path_len.into(); - if (inode_val.name.len() as u64) < path_len { + if (inode_val.name.len() as u64) <= path_len { wasi_try_mem!(path_chars .subslice(0..inode_val.name.len() as u64) .write_slice(inode_val.name.as_bytes())); - wasi_try_mem!(path_chars.index(inode_val.name.len() as u64).write(0)); trace!("=> result: \"{}\"", inode_val.name);