Skip to content

[6.0] Prevent null character in Windows home directory #813

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
Aug 5, 2024

Conversation

jrflat
Copy link
Contributor

@jrflat jrflat commented Aug 2, 2024

Explanation: Prevents a null-terminator from the Windows home directory API from ending up in the resulting String or URL. Prevents %00 from being decoded to \0 when getting a URL's fileSystemPath, which is often converted to a C string for file system calls.
Scope: Windows-only change from String(decoding:) to String(decodingCString:) for homeDirectoryPath(forUser:). Not decoding %00 occurs for file paths of URLs on all platforms.
Original PR: #808
Risk: Low. Minor changes to prevent unexpected behavior when null-characters are included in file paths. The respective Windows APIs null-terminate their output, so String(decodingCString:) is safe.
Testing: swift-ci testing and local testing on Windows
Reviewers: @compnerd @jmschonfeld

@jrflat
Copy link
Contributor Author

jrflat commented Aug 2, 2024

@swift-ci please test

@jrflat jrflat requested review from parkera and itingliu August 2, 2024 16:30
@jrflat jrflat merged commit 40ca820 into swiftlang:release/6.0 Aug 5, 2024
3 checks passed
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