Browse Source

wasi-common: fix fdstat of dirfd

the fdstat of a dirfd needs to include both the file and dir rights in
the inheriting field.

The wasi-libc path_open bases the base rights of child directories off
the inheriting rights of the parent, so if we only put file rights in
there, opening a child directory will not have any directory operations
permitted.

Fixes https://github.com/bytecodealliance/wasmtime/issues/2638
pull/2652/head
Pat Hickey 4 years ago
committed by Dan Gohman
parent
commit
c9d8ed03c9
  1. 2
      crates/wasi-common/src/snapshots/preview_1.rs

2
crates/wasi-common/src/snapshots/preview_1.rs

@ -1112,7 +1112,7 @@ impl From<&FdStat> for types::Fdstat {
impl From<&DirFdStat> for types::Fdstat {
fn from(dirstat: &DirFdStat) -> types::Fdstat {
let fs_rights_base = types::Rights::from(&dirstat.dir_caps);
let fs_rights_inheriting = types::Rights::from(&dirstat.file_caps);
let fs_rights_inheriting = types::Rights::from(&dirstat.file_caps) | fs_rights_base;
types::Fdstat {
fs_filetype: types::Filetype::Directory,
fs_rights_base,

Loading…
Cancel
Save