From f357daa5da2527fcd6cd2842e105fc7db7ad1e02 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Tue, 9 Feb 2021 15:43:52 -0800 Subject: [PATCH] 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 --- crates/wasi-common/src/snapshots/preview_1.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wasi-common/src/snapshots/preview_1.rs b/crates/wasi-common/src/snapshots/preview_1.rs index 9285038f16d7..e6db3fb761db 100644 --- a/crates/wasi-common/src/snapshots/preview_1.rs +++ b/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,