Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WASI Path Mapping Processing #3923

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dpjohnst
Copy link

Filesystem paths can be mapped from the host path to a guest path using the format <guest-path>::<host-path>.

Previously strtok was used to find the :: delimiter. Unfortunately strtok processes each delimiter character individually. This meant that the code was ~equivalent to strtok(mapping_copy, ":") which breaks with Windows-style paths (E.g. C:\my_path\).

To fix this strstr is used to search for the exact delimiter.

Filesystem paths can be mapped from the host path to a guest path using
the format `<guest-path>::<host-path>`.

Previously `strtok` was used to find the `::` delimiter. Unfortunately
`strtok` processes each delimiter character individually. This meant
that the code was ~equivalent to `strtok(mapping_copy, ":")` which
breaks with Windows-style paths (E.g. `C:\my_path\`).

To fix this `strstr` is used to search for the exact delimiter.
@dpjohnst dpjohnst marked this pull request as ready for review November 21, 2024 22:41
if (delim_pos) {
*delim_pos = '\0';
map_mapped = mapping_copy;
map_host = delim_pos + strlen(delim);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map_host may be an empty string "", do you think we should check whether strlen(map_host) == 0, and if yes, set map_host to NULL to let runtime report error and exit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants