-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
'.' and '..' components in relative paths in std.os.windows.OpenFile #6044
Labels
Milestone
Comments
Related: #4659 |
Nice, thanks @squeek502! |
Here's an easy way to reproduce this: The compiler fails with > mkdir src
> echo "" > src\bug.zig
> zig build-obj src\..\src\bug.zig
error: Unexpected |
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
While working on #5701 and #5993 I've noticed that doing something like this on Windows:
will yield a runtime panic (actually,
NtCreateFile
will trip onOBJECT_NAME_INVALID
). As far as I can work out, this is due to the presence of '.' and '..' in the pathname argument. My question is here, is there any simple way around this, or are we forced to re-implementCreateFileW
where we either query the OS for the handle to cwd, or we use the.dir
handle, get the canonical path to it usingGetFinalPathNameByHandle
, concatenate the resultant path with the specified argument path, and feed this path intoNtCreateFile
again (not sure if that would even work since I'd imagine we'd prepend\??\
to the resultant path which could potentially not accept '.' and '..' as valid path components)?I'm not yet convinced whether we'd want to enable this kind of behaviour for all calls using
std.os.windows.OpenFile
, however, it does seem useful forstd.os.realpath
andstd.fs.Dir.realpath
, when canonicalizing the pathnames.The text was updated successfully, but these errors were encountered: