8266291: (jrtfs) Calling Files.exists may break the JRT filesystem

Reviewed-by: redestad, alanb
This commit is contained in:
Athijegannathan Sundararajan 2021-05-14 12:59:41 +00:00
parent ebcf3991b7
commit af4cd04c2e
2 changed files with 35 additions and 4 deletions

View file

@ -468,6 +468,19 @@ public final class ImageReader implements AutoCloseable {
Node handleResource(String name) {
Node n = null;
if (!name.startsWith("/modules/")) {
return null;
}
// Make sure that the thing that follows "/modules/" is a module name.
int moduleEndIndex = name.indexOf('/', "/modules/".length());
if (moduleEndIndex == -1) {
return null;
}
ImageLocation moduleLoc = findLocation(name.substring(0, moduleEndIndex));
if (moduleLoc == null || moduleLoc.getModuleOffset() == 0) {
return null;
}
String locationPath = name.substring("/modules".length());
ImageLocation resourceLoc = findLocation(locationPath);
if (resourceLoc != null) {