Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed trailing zero in WASI::fd_prestat_dir_name name return (for #3025) #3061

Merged
merged 3 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/wasi/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
Expand Down
4 changes: 1 addition & 3 deletions lib/wasi/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -969,13 +969,11 @@ pub fn fd_prestat_dir_name<M: MemorySize>(
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));
ptitSeb marked this conversation as resolved.
Show resolved Hide resolved

trace!("=> result: \"{}\"", inode_val.name);

Expand Down