Mercurial > hg > release > icedtea6-1.8
changeset 2046:933009b1b7c4
netx: handle JNLP files which use native libraries but do not indiate it
2010-06-24 Omair Majid <omajid@redhat.com>
* netx/net/sourceforge/jnlp/SecurityDesc.java: Fix comments.
* netx/net/sourceforge/jnlp/JNLPClassLoader.java
(activateJars): Always call activateNative.
(activateNative): Search for native code anywhere in the jar.
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Thu, 24 Jun 2010 09:40:43 -0400 |
parents | 872cddeeb5cc |
children | ec12891f51bc |
files | ChangeLog netx/net/sourceforge/jnlp/SecurityDesc.java netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java |
diffstat | 3 files changed, 35 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Jun 29 15:48:10 2010 -0400 +++ b/ChangeLog Thu Jun 24 09:40:43 2010 -0400 @@ -1,3 +1,10 @@ +2010-06-24 Omair Majid <omajid@redhat.com> + + * netx/net/sourceforge/jnlp/SecurityDesc.java: Fix comments. + * netx/net/sourceforge/jnlp/JNLPClassLoader.java + (activateJars): Always call activateNative. + (activateNative): Search for native code anywhere in the jar. + 2010-06-29 Omair Majid <omajid@redhat.com> * netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
--- a/netx/net/sourceforge/jnlp/SecurityDesc.java Tue Jun 29 15:48:10 2010 -0400 +++ b/netx/net/sourceforge/jnlp/SecurityDesc.java Thu Jun 24 09:40:43 2010 -0400 @@ -31,12 +31,9 @@ */ public class SecurityDesc { - // todo: make sure classloader's native code support checks - // the security permissions - - // shouldn't need to verify that native code only runs in - // trusted environment because the parser and/or classloader - // should kick it. + /* + * We do not verify security here, the classloader deals with security + */ /** All permissions. */ public static final Object ALL_PERMISSIONS = "All";
--- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Tue Jun 29 15:48:10 2010 -0400 +++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Thu Jun 24 09:40:43 2010 -0400 @@ -81,9 +81,6 @@ /** map from JNLPFile url to shared classloader */ private static Map urlToLoader = new HashMap(); // never garbage collected! - /** number of times a classloader with native code is created */ - private static int nativeCounter = 0; - /** the directory for native code */ private File nativeDir = null; // if set, some native code exists @@ -650,8 +647,8 @@ ex.printStackTrace(); } - if (jar.isNative()) - activateNative(jar); + // some programs place a native library in any jar + activateNative(jar); } return null; @@ -662,9 +659,9 @@ } /** - * Enable the native code contained in a JAR by copying the - * native files into the filesystem. Called in the security - * context of the classloader. + * Search for and enable any native code contained in a JAR by copying the + * native files into the filesystem. Called in the security context of the + * classloader. */ protected void activateNative(JARDesc jar) { if (JNLPRuntime.isDebug()) @@ -677,17 +674,33 @@ if (nativeDir == null) nativeDir = getNativeDir(); + String[] librarySuffixes = { ".so", ".dylib", ".jnilib", ".framework", ".dll" }; + try { JarFile jarFile = new JarFile(localFile, false); - Enumeration entries = jarFile.entries(); + Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { - JarEntry e = (JarEntry) entries.nextElement(); + JarEntry e = entries.nextElement(); + + if (e.isDirectory()) { + continue; + } + + String name = new File(e.getName()).getName(); + boolean isLibrary = false; - if (e.isDirectory() || e.getName().indexOf('/') != -1) + for (String suffix: librarySuffixes) { + if (name.endsWith(suffix)) { + isLibrary = true; + break; + } + } + if (!isLibrary) { continue; + } - File outFile = new File(nativeDir, e.getName()); + File outFile = new File(nativeDir, name); CacheUtil.streamCopy(jarFile.getInputStream(e), new FileOutputStream(outFile));