Skip to content

Fix temporary filename coda going above the maximum path length in some cases #3005

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

Merged
merged 1 commit into from
Jul 13, 2021
Merged

Fix temporary filename coda going above the maximum path length in some cases #3005

merged 1 commit into from
Jul 13, 2021

Conversation

millenomi
Copy link
Contributor

@millenomi millenomi commented Jul 12, 2021

This fixes an issue that would occur if the filename for a temporary file plus the .tmp.<coda> suffix was beyond the maximum path limit, but would be fine without it. This limits the temp filename to a maximum of 31 characters.

There will be follow-ups for other situations where long paths have similar issues, but this one specifically is also going to be nominated for 5.4.x and 5.5.

Fixes https://bugs.swift.org/browse/SR-14823.

…porary directory paths by hashing the filename for the mkstemp template

This limits the temp filename to a maximum of 31 characters.
Fixes <https://bugs.swift.org/browse/SR-14823>.
@millenomi millenomi changed the title Ensure long file names do not cause too-long-path issues for long temporary directory paths by hashing the filename for the mkstemp template Fix temporary filename coda going above the maximum path length in some cases Jul 12, 2021
@millenomi
Copy link
Contributor Author

cc @compnerd is Windows atomic writing broken? The Windows path above this seems to be using the temporary directory always, which may mean that .atomic writes on a volume other than C: (or wherever the temp directory ends up being) may fail due to rename() failing.

@millenomi
Copy link
Contributor Author

Never mind — it uses CopyFileW. It looks like the .atomic path is thus not atomic at all >.<

@millenomi
Copy link
Contributor Author

@swift-ci please test

@millenomi
Copy link
Contributor Author

@swift-ci please test macOS

@millenomi millenomi merged commit 62c50ad into swiftlang:main Jul 13, 2021
@millenomi millenomi deleted the pr/sr-14823 branch July 13, 2021 19:54
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.

1 participant