6891707: Eliminate the java.io.FilePermission dependency on PolicyFile
Replace call to PolicyFile.canonPath with its own implementation Reviewed-by: alanb, mullan
This commit is contained in:
parent
1d9e85adb5
commit
9c1ea09b07
@ -209,7 +209,17 @@ public final class FilePermission extends Permission implements Serializable {
|
|||||||
cpath = AccessController.doPrivileged(new PrivilegedAction<String>() {
|
cpath = AccessController.doPrivileged(new PrivilegedAction<String>() {
|
||||||
public String run() {
|
public String run() {
|
||||||
try {
|
try {
|
||||||
return sun.security.provider.PolicyFile.canonPath(cpath);
|
String path = cpath;
|
||||||
|
if (cpath.endsWith("*")) {
|
||||||
|
// call getCanonicalPath with a path with wildcard character
|
||||||
|
// replaced to avoid calling it with paths that are
|
||||||
|
// intended to match all entries in a directory
|
||||||
|
path = path.substring(0, path.length()-1) + "-";
|
||||||
|
path = new File(path).getCanonicalPath();
|
||||||
|
return path.substring(0, path.length()-1) + "*";
|
||||||
|
} else {
|
||||||
|
return new File(path).getCanonicalPath();
|
||||||
|
}
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
return cpath;
|
return cpath;
|
||||||
}
|
}
|
||||||
|
@ -1832,8 +1832,9 @@ public class PolicyFile extends java.security.Policy {
|
|||||||
return canonCs;
|
return canonCs;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public for java.io.FilePermission
|
// Wrapper to return a canonical path that avoids calling getCanonicalPath()
|
||||||
public static String canonPath(String path) throws IOException {
|
// with paths that are intended to match all entries in the directory
|
||||||
|
private static String canonPath(String path) throws IOException {
|
||||||
if (path.endsWith("*")) {
|
if (path.endsWith("*")) {
|
||||||
path = path.substring(0, path.length()-1) + "-";
|
path = path.substring(0, path.length()-1) + "-";
|
||||||
path = new File(path).getCanonicalPath();
|
path = new File(path).getCanonicalPath();
|
||||||
|
Loading…
Reference in New Issue
Block a user