You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
path_open should error if the input path ends with a / but points to an existing regular file. This is the behavior on native Linux, WAMR, WasmEdge, Wasmtime, and Wazero.
Steps to reproduce
This standalone snippet can be added to wasi-fyi test suite.
#[link(wasm_import_module = "wasi_snapshot_preview1")]extern"C"{pubfnpath_open(fd:i32,dirflags:i32,path:i32,path_len:i32,oflags:i32,fs_rights_base:i64,fs_rights_inheriting:i64,fdflags:i32,result_fd:i32,) -> i32;}constERRNO_SUCCESS:i32 = 0;constERRNO_NOTDIR:i32 = 54;constRIGHTS_FD_READ:i64 = 2;fnmain(){unsafe{let fd = 5;let path_ok = "fyi/fs_open_trailing_slash.dir/file";let path_bad = "fyi/fs_open_trailing_slash.dir/file/";let errno = path_open(
fd,0,
path_ok.as_ptr()asi32,
path_ok.len()asi32,0,RIGHTS_FD_READ,0,0,1024,);assert_eq!(
errno,ERRNO_SUCCESS,"opening a file without a trailing slash works");let errno = path_open(
fd,0,
path_bad.as_ptr()asi32,
path_bad.len()asi32,0,RIGHTS_FD_READ,0,0,1024,);assert_eq!(
errno,ERRNO_NOTDIR,"opening a regular file with a trailing slash should fail");}}
Expected behavior
path_open should error with notdir (54).
Actual behavior
path_open succeeds.
Additional context
This issue is not present when compiled with wasi-sdk. Probably because wasi-sdk performs this check.
The text was updated successfully, but these errors were encountered:
yagehu
added a commit
to yagehu/wasmer
that referenced
this issue
Jun 7, 2024
This commit fixes `path_open` sometimes ignoring the trailing slash. On
host Linux and other runtimes, opening an existing file with a path
containing a trailing slash fails, but wasmer succeeds.
fixeswasmerio#4820
This commit fixes `path_open` sometimes ignoring the trailing slash. On
host Linux and other runtimes, opening an existing file with a path
containing a trailing slash fails, but wasmer succeeds.
fixeswasmerio#4820
Describe the bug
path_open
should error if the input path ends with a/
but points to an existing regular file. This is the behavior on native Linux, WAMR, WasmEdge, Wasmtime, and Wazero.Steps to reproduce
This standalone snippet can be added to
wasi-fyi
test suite.Expected behavior
path_open
should error withnotdir
(54).Actual behavior
path_open
succeeds.Additional context
This issue is not present when compiled with wasi-sdk. Probably because wasi-sdk performs this check.
The text was updated successfully, but these errors were encountered: