Skip to content

Commit

Permalink
Merge #3061
Browse files Browse the repository at this point in the history
3061: Removed trailing zero in WASI::fd_prestat_dir_name name return (for #3025) r=ptitSeb a=ptitSeb

# Description
Removed trailing zero in WASI::fd_prestat_dir_name returned name (for #3025)

Co-authored-by: ptitSeb <[email protected]>
  • Loading branch information
bors[bot] and ptitSeb authored Oct 13, 2022
2 parents 6fb179f + fc719c5 commit 5db56ce
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
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));

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

Expand Down

0 comments on commit 5db56ce

Please sign in to comment.