[all-commits] [llvm/llvm-project] c60471: [Support][Windows] Make sure only executables are ...
zero9178 via All-commits
all-commits at lists.llvm.org
Thu Mar 25 12:30:07 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: c6047101ad5fc1f0c88a402bb5029949a216b2cf
https://github.com/llvm/llvm-project/commit/c6047101ad5fc1f0c88a402bb5029949a216b2cf
Author: Markus Böck <markus.boeck02 at gmail.com>
Date: 2021-03-25 (Thu, 25 Mar 2021)
Changed paths:
M llvm/lib/Support/Windows/Path.inc
M llvm/lib/Support/Windows/Program.inc
M llvm/unittests/Support/Path.cpp
Log Message:
-----------
[Support][Windows] Make sure only executables are found by sys::findProgramByName
The function utilizes Windows' SearchPathW function, which as I found out today, may also return directories. After looking at the Unix implementation of the file I found that it contains a check whether the found path is also executable. While fixing the Windows implementation, I also learned that sys::fs::access returns successfully when querying whether directories are executable, which the Unix version does not.
This patch makes both of these functions equivalent to their Unix implementation and insures that any path returned by sys::findProgramByName on Windows may only be executable, just like the Unix implementation.
The equivalent additions I have made to the Windows implementation, in the Unix implementation are here:
sys::findProgramByName: https://github.com/llvm/llvm-project/blob/39ecfe614350fa5db7b8f13f81212f8e3831a390/llvm/lib/Support/Unix/Program.inc#L90
sys::fs::access: https://github.com/llvm/llvm-project/blob/c2a84771bb63947695ea50b89160c02b36fb634d/llvm/lib/Support/Unix/Path.inc#L608
I encountered this issue when running the LLVM testsuite. Commands of the form not test ... would fail to correctly execute test.exe, which is part of GnuWin32, as it actually tried to execute a folder called test, which happened to be in a directory on my PATH.
Differential Revision: https://reviews.llvm.org/D99357
More information about the All-commits
mailing list