Open neild opened 1 month ago
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Hmm, the problem seems to be that wasip1 is performing path cleaning in general prior to opening files, which is going to affect more than just a trailing "/.".
This produces incorrect results in a variety of situations, or at least results inconsistent with the usual behavior of Unix filesystems.
Open("a/../b")
should be an error if a does not exist, or is a non-directory file.Open("symlink/../b")
should resolve any symlink in the first path component, and then open b in the parent of the linked-to directory.Open("a/")
should be an error if a is a non-directory file.Testing with wasmtime, the WASI file API functions all seem to behave as I'd expect here (modulo what seems to be one bug: https://github.com/bytecodealliance/wasmtime/issues/9272). The additional path-cleaning behavior is being added in the Go runtime, and I don't believe it's correct.
I sent a patch that fixes file/.
issue, but I need to investigate further for subsequent issues.
Change https://go.dev/cl/614083 mentions this issue: syscall: add separator for filepath if contains "." in waspi
Go version
master
Output of
go env
in your module/workspace:What did you do?
What did you see happen?
When built with GOOS=wasip1, the os package performs some path cleaning on filenames which results in a terminal "/." being removed. This causes opening a non-directory file to unexpectedly succeed.
What did you expect to see?
An error opening "file/.", because "file" is not a directory.