Add a WASI test for a creating an absolute-path symlink. (#6166)
Wasmtime disallows guests from using `path_symlink` to create absolute-path symlinks, as they could confuse other code into accessing resources on the host that the guest otherwise doesn't have access to. This patch adds a test for this behavior.
This commit is contained in:
@@ -62,6 +62,11 @@ unsafe fn create_symlink_to_directory(dir_fd: wasi::Fd) {
|
|||||||
.expect("remove_directory on a directory should succeed");
|
.expect("remove_directory on a directory should succeed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe fn create_symlink_to_root(dir_fd: wasi::Fd) {
|
||||||
|
// Create a symlink.
|
||||||
|
wasi::path_symlink("/", dir_fd, "symlink").expect_err("creating a symlink to an absolute path");
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut args = env::args();
|
let mut args = env::args();
|
||||||
let prog = args.next().unwrap();
|
let prog = args.next().unwrap();
|
||||||
@@ -85,5 +90,6 @@ fn main() {
|
|||||||
unsafe {
|
unsafe {
|
||||||
create_symlink_to_file(dir_fd);
|
create_symlink_to_file(dir_fd);
|
||||||
create_symlink_to_directory(dir_fd);
|
create_symlink_to_directory(dir_fd);
|
||||||
|
create_symlink_to_root(dir_fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user