Skip to content

path_symlink crashes runtime #4899

@yagehu

Description

@yagehu

Describe the bug

Calling path_symlink with a non-directory descriptor and a new_path with only one component crashes Wasmer.

fn main() {
    unsafe {
        let base_fd = 5;
        let fd = wasi::path_open(
            base_fd,
            0,
            "dir/a",
            wasi::OFLAGS_CREAT,
            wasi::RIGHTS_FD_WRITE,
            0,
            0,
        )
        .unwrap();

        wasi::path_symlink("a", fd, "link").unwrap();
    }
}

Wasmer commit: fb9a04b

Steps to reproduce

Compile the snippet with wasi crate v0.11 and run with wasmer:

cargo build --target wasm32-wasi
wasmer run --mapdir /dir:. target/wasm32-wasi/debug/example.wasm

Expected behavior

The function should return a error code.

Actual behavior

Wasmer panics:

thread 'main' panicked at lib/wasix/src/syscalls/wasi/path_symlink.rs:104:17:
internal error: entered unreachable code: get_parent_inode_at_path returned something other than a Dir or Root

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpriority-highHigh priority issue🏚 staleInactive issues or PR📦 lib-vfsAbout wasmer-vfs

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions