nodejs / uvwasi

WASI syscall API built atop libuv
MIT License
225 stars 49 forks source link

fix: resolving relative paths in symlinks #224

Closed shqld closed 8 months ago

shqld commented 1 year ago

This fixes https://github.com/nodejs/node/issues/49107 (relative paths in symlinks resolved incorrectly).

When following a symbolic link that points to a target using a relative path, the uvwasi__resolve_path() function resolves and normalizes the link's target as a relative path starting from fd->real_path. This should be treated as a relative path starting from the parent directory of the symbolic link.

For example, given the directory structure below:

.
├── source_file
└── dir
    └── link -> ../source_file

When fd->real_path is ., the link target for link is resolved as ../source_file, not ./source_file. As a result, this resolution ends with an ENOTCAPABLE error.

cjihrig commented 1 year ago

Thanks for the PR. It looks like there is a compilation error: https://github.com/nodejs/uvwasi/actions/runs/5854703133/job/15876962601

shqld commented 1 year ago

Sorry, I forgot to remove the unused variable 🤦🏼 and fixed another memory problem in tests.