Resolve Executable.name(_:) against PATH only on every platform - #359
Merged
iCharlesHu merged 1 commit intoAug 4, 2026
Merged
Conversation
Contributor
Author
|
Resolves: #357 |
Executable.name(_:) is documented as a PATH lookup, but it also searched a current directory ahead of PATH. This behavior is opposite of what every POSIX runtime agreed on, and it allows potential arbitrary execution. Update Executable.name(_:) such that an executable name now resolves the same way on all platforms: by walking the PATH the subprocess will receive, falling back to the current process's value and then to the directories the platform reports as standard (confstr(_CS_PATH) on Unix, the CreateProcessW search list without the current directory on Windows). Empty and relative entries are skipped, so every resolved path is absolute and resolveExecutablePath(in:) agrees with the spawn path, and a name containing a path separator is now rejected with spawnFailed rather than resolved against a current directory.
iCharlesHu
force-pushed
the
charles/executable-name-resolution
branch
from
July 31, 2026 16:14
fd7e1d5 to
f70630f
Compare
jakepetroules
approved these changes
Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Executable.name(_:)is documented as aPATHlookup, but it also searched a current directory ahead ofPATH. This behavior is opposite of what every POSIX runtime agreed on, and it allows potential arbitrary execution. UpdateExecutable.name(_:)such that an executable name now resolves the same way on all platforms: by walking thePATHthe subprocess will receive, falling back to the current process's value and then to the directories the platform reports as standard (confstr(_CS_PATH)on Unix, theCreateProcessWsearch list without the current directory on Windows). Empty and relative entries are skipped, so every resolved path is absolute andresolveExecutablePath(in:)agrees with the spawn path, and a name containing a path separator is now rejected withspawnFailedrather than resolved against a current directory.