Skip to content

Commit 62b3718

Browse files
committed
More robust checking of parent path on Windows
1 parent f5e2a92 commit 62b3718

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/FileAccessTree.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ private static boolean checkPath(String path, String[] paths) {
9898
int ndx = Arrays.binarySearch(paths, path);
9999
if (ndx < -1) {
100100
String maybeParent = paths[-ndx - 2];
101-
return path.startsWith(maybeParent) && path.startsWith(FILE_SEPARATOR, maybeParent.length());
101+
// Normalization on Windows does not allways remove trailing backslashes, we need to check both patterns
102+
return path.startsWith(maybeParent)
103+
&& (maybeParent.endsWith(FILE_SEPARATOR) || path.startsWith(FILE_SEPARATOR, maybeParent.length()));
102104
}
103105
return ndx >= 0;
104106
}

0 commit comments

Comments
 (0)