8047904: Runtime.loadLibrary throws SecurityException when security manager is installed
Reviewed-by: alanb, psandoz
This commit is contained in:
parent
0caae2d748
commit
bfe7a7abd1
@ -1859,18 +1859,17 @@ public abstract class ClassLoader {
|
||||
String name = NativeLibrary.findBuiltinLib(file.getName());
|
||||
boolean isBuiltin = (name != null);
|
||||
if (!isBuiltin) {
|
||||
boolean exists = AccessController.doPrivileged(
|
||||
new PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
return file.exists() ? Boolean.TRUE : null;
|
||||
}})
|
||||
!= null;
|
||||
if (!exists) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
name = file.getCanonicalPath();
|
||||
} catch (IOException e) {
|
||||
name = AccessController.doPrivileged(
|
||||
new PrivilegedAction<String>() {
|
||||
public String run() {
|
||||
try {
|
||||
return file.exists() ? file.getCanonicalPath() : null;
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (name == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ public class Launcher {
|
||||
* look in the extension directory itself.
|
||||
*/
|
||||
public String findLibrary(String name) {
|
||||
name = System.mapLibraryName(name);
|
||||
final String libname = System.mapLibraryName(name);
|
||||
URL[] urls = super.getURLs();
|
||||
File prevDir = null;
|
||||
for (int i = 0; i < urls.length; i++) {
|
||||
@ -216,17 +216,26 @@ public class Launcher {
|
||||
if (dir != null && !dir.equals(prevDir)) {
|
||||
// Look in architecture-specific subdirectory first
|
||||
// Read from the saved system properties to avoid deadlock
|
||||
String arch = VM.getSavedProperty("os.arch");
|
||||
if (arch != null) {
|
||||
File file = new File(new File(dir, arch), name);
|
||||
if (file.exists()) {
|
||||
return file.getAbsolutePath();
|
||||
}
|
||||
}
|
||||
// Then check the extension directory
|
||||
File file = new File(dir, name);
|
||||
if (file.exists()) {
|
||||
return file.getAbsolutePath();
|
||||
final String arch = VM.getSavedProperty("os.arch");
|
||||
String pathname = AccessController.doPrivileged(
|
||||
new PrivilegedAction<String>() {
|
||||
public String run() {
|
||||
if (arch != null) {
|
||||
File file = new File(new File(dir, arch), libname);
|
||||
if (file.exists()) {
|
||||
return file.getAbsolutePath();
|
||||
}
|
||||
}
|
||||
// Then check the extension directory
|
||||
File file = new File(dir, libname);
|
||||
if (file.exists()) {
|
||||
return file.getAbsolutePath();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
if (pathname != null) {
|
||||
return pathname;
|
||||
}
|
||||
}
|
||||
prevDir = dir;
|
||||
|
Loading…
x
Reference in New Issue
Block a user