harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r520360 - in /harmony/enhanced/classlib/trunk/modules: archive/src/main/java/java/util/jar/JarVerifier.java luni/src/main/java/java/net/URLClassLoader.java luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest.java
Date Tue, 20 Mar 2007 11:21:50 GMT
Author: pyang
Date: Tue Mar 20 04:21:49 2007
New Revision: 520360

URL: http://svn.apache.org/viewvc?view=rev&rev=520360
Log:
Apply patch for HARMONY-3332 ([classlib][luni]URLClassLoader throws NullPointerException while
load an implementation class of a security provider in a jar which is signed.)

Modified:
    harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarVerifier.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLClassLoader.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest.java

Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarVerifier.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarVerifier.java?view=diff&rev=520360&r1=520359&r2=520360
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarVerifier.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarVerifier.java
Tue Mar 20 04:21:49 2007
@@ -273,6 +273,13 @@
             Certificate[] signerCertChain = JarUtils.verifySignature(
                     new ByteArrayInputStream(sfBytes),
                     new ByteArrayInputStream(sBlockBytes));
+            /*
+             * Recursive call in loading security provider related class which
+             * is in a signed jar. 
+             */
+            if (null == metaEntries) {
+                return;
+            }
             if (signerCertChain != null) {
                 certificates.put(signatureFile, signerCertChain);
             }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLClassLoader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLClassLoader.java?view=diff&rev=520360&r1=520359&r2=520360
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLClassLoader.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLClassLoader.java
Tue Mar 20 04:21:49 2007
@@ -1086,6 +1086,16 @@
                         if (entry != null) {
                             readAvailable = true;
                             is = jf.getInputStream(entry);
+                            /**
+                             * Avoid recursive load class, especially the class
+                             * is an implementation class of security provider
+                             * and the jar is signed.
+                             */
+                            Class loadedClass = findLoadedClass(clsName);
+                            if (null != loadedClass) {
+                                is.close();
+                                return loadedClass;
+                            }
                             manifest = jf.getManifest();
                         }
                     } else if (protocol.equals("file")) { //$NON-NLS-1$

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest.java?view=diff&rev=520360&r1=520359&r2=520360
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ClassTest.java
Tue Mar 20 04:21:49 2007
@@ -36,6 +36,7 @@
 import java.security.Permission;
 import java.security.PrivilegedAction;
 import java.security.ProtectionDomain;
+import java.security.Security;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Vector;
@@ -158,6 +159,14 @@
             fail("should throw ClassNotFoundException.");
         } catch (ClassNotFoundException e) {
         }
+        
+        //Regression Test for HARMONY-3332
+        String securityProviderClassName;
+        int count = 1;
+        while ((securityProviderClassName = Security
+                .getProperty("security.provider." + count++)) != null) {
+            Class.forName(securityProviderClassName);
+        }       
     }
 
     /**



Mime
View raw message