aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2021-08-13 09:36:26 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2021-08-17 16:48:19 +0200
commit5fb71fb54e5d1bc2f5164c7f1ffdfacfa6a69b62 (patch)
treefd49b95ac31cad5ac839c9560a6881c4274c22e8 /org.eclipse.jgit
parent3cd7eb1b23dcf3d0477e8cd22a57f1b799a5ba5f (diff)
downloadjgit-5fb71fb54e5d1bc2f5164c7f1ffdfacfa6a69b62.tar.gz
jgit-5fb71fb54e5d1bc2f5164c7f1ffdfacfa6a69b62.zip
Ensure FS#searchPath only selects executable files
On Posix non executable files on the path should be ignored, on Windows File#canExecute always returns true. While we are here also add missing braces. Bug: 575385 Change-Id: I80cd5057bdf9632a17f103db6f1356e975b6e150
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
index 0946f645fb..4a4034794e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
@@ -1267,7 +1267,8 @@ public abstract class FS {
/**
* Searches the given path to see if it contains one of the given files.
- * Returns the first it finds. Returns null if not found or if path is null.
+ * Returns the first it finds which is executable. Returns null if not found
+ * or if path is null.
*
* @param path
* List of paths to search separated by File.pathSeparator
@@ -1277,14 +1278,15 @@ public abstract class FS {
* @since 3.0
*/
protected static File searchPath(String path, String... lookFor) {
- if (path == null)
+ if (path == null) {
return null;
+ }
for (String p : path.split(File.pathSeparator)) {
for (String command : lookFor) {
final File file = new File(p, command);
try {
- if (file.isFile()) {
+ if (file.isFile() && file.canExecute()) {
return file.getAbsoluteFile();
}
} catch (SecurityException e) {