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

curl_multibyte: support Windows paths longer than MAX_PATH #13522

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jay
Copy link
Member

@jay jay commented May 3, 2024

  • Add a helper function for the Windows file wrapper functions that will normalize a long path (or a filename in a long path) and add the prefix \\?\ so that Windows will access the file.

Prior to this change if a filename (when normalized internally by Windows to its full path) or a path was longer than MAX_PATH (260) then Windows would not open the path, unless it was already normalized by the user and had the \\?\ prefix prepended.

The \\?\ prefix could not be passed to file:// so for example something like file://c:/foo/bar/filename255chars could not be opened prior to this change.

There's some code in tool_doswin that will need to be modified as well to further remove MAX_PATH (aka PATH_MAX) limitation.

Ref: #8361
Ref: #13512
Ref: https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats
Ref: https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation

Closes #xxxx

- Add a helper function for the Windows file wrapper functions that will
  normalize a long path (or a filename in a long path) and add the
  prefix `\\?\` so that Windows will access the file.

Prior to this change if a filename (when normalized internally by
Windows to its full path) or a path was longer than MAX_PATH (260) then
Windows would not open the path, unless it was already normalized by the
user and had the `\\?\` prefix prepended.

The `\\?\` prefix could not be passed to file:// so for example
something like file://c:/foo/bar/filename255chars could not be opened
prior to this change.

There's some code in tool_doswin that will need to be modified as well
to further remove MAX_PATH (aka PATH_MAX) limitation.

Ref: curl#8361
Ref: curl#13512
Ref: https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats
Ref: https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation

Closes #xxxx
@jay jay added the Windows Windows-specific label May 3, 2024
lib/curl_multibyte.c Outdated Show resolved Hide resolved
jay added 2 commits May 3, 2024 18:53
- explain 32767 constant is "approximate" maximum path len, so says MS.

- explain GetFullPathNameW returns a normalized full path and what it
  means to normalize.

- fix `\\?\` logic to restrict the times when it is prepended, since it
  may already be prepended.

- skip excessively long path input if it's already prefixed with `\\?\`
  (likely by the user)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Windows Windows-specific
Development

Successfully merging this pull request may close these issues.

None yet

3 participants