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

package fetching: path separators in symlinks are not normalized #17549

Closed
andrewrk opened this issue Oct 16, 2023 · 0 comments · Fixed by #17562
Closed

package fetching: path separators in symlinks are not normalized #17549

andrewrk opened this issue Oct 16, 2023 · 0 comments · Fixed by #17562
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. os-windows zig build system std.Build, the build runner, `zig build` subcommand, package management
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Oct 16, 2023

Here you can see that symlink data is passed directly to the hasher:

zig/src/Package/Fetch.zig

Lines 1430 to 1433 in ca690ff

.sym_link => {
const link_name = try dir.readLink(hashed_file.fs_path, &buf);
hasher.update(link_name);
},

This leads to incorrect package hashes on Windows when the unpacked directory of files has any symlinks with path separators in them.

Instead, on Windows only, back slashes need to be normalized into forward slashes.

Example - this is the expected results, and what happens on Linux:

$ zig fetch https://github.com/mitchellh/zig-build-macos-sdk/archive/166ff65bb7688c0a08c4ea98166ec8300aa34128.tar.gz
1220bfe1b32491a3448dff55c1dc0c12aa573f1e5bdb0a962bfbadaaa59e4833798b

However, on Windows, it gives an incorrect result:

PS C:\> zig.exe fetch https://github.com/mitchellh/zig-build-macos-sdk/archive/166ff65bb7688c0a08c4ea98166ec8300aa34128.tar.gz
1220505223f0f4e7208583416b19e3c913992218062b2ba8e41018364e7a5a8e93ae
@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. os-windows zig build system std.Build, the build runner, `zig build` subcommand, package management labels Oct 16, 2023
@andrewrk andrewrk added this to the 0.12.0 milestone Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. os-windows zig build system std.Build, the build runner, `zig build` subcommand, package management
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant