Skip to content

Commit 8eaf39d

Browse files
committed
Fix PathUtils to implicitly allow canonical children
As for IndexDatabase, PathUtils should implicitly allow a symlink whose target is a canonical child of another explicitly-allowed symlink.
1 parent 282603f commit 8eaf39d

File tree

1 file changed

+4
-2
lines changed
  • opengrok-indexer/src/main/java/org/opengrok/indexer/util

1 file changed

+4
-2
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/util/PathUtils.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public static String getRelativeToCanonical(String path, String canonical)
7171
* <p>
7272
* When {@code allowedSymlinks} is not null, any symbolic links as
7373
* components of {@code path} (below {@code canonical}) are required to
74-
* match an element of {@code allowedSymlinks}.
74+
* match an element of {@code allowedSymlinks} or target a canonical child
75+
* of an element of {@code allowedSymlinks}.
7576
* <p>
7677
* E.g., with {@code path="/var/opengrok/src/proj_a"} and
7778
* {@code canonical="/private/var/opengrok/src"} where /var is linked to
@@ -176,7 +177,8 @@ private static boolean isAllowedSymlink(String canonicalFile,
176177
}
177178
continue;
178179
}
179-
if (canonicalFile.equals(canonicalLink)) {
180+
if (canonicalFile.equals(canonicalLink) ||
181+
canonicalFile.startsWith(canonicalLink + File.separator)) {
180182
return true;
181183
}
182184
}

0 commit comments

Comments
 (0)