changeset 13333:d42dc38b9397

8208754: The fix for JDK-8194534 needs updates Reviewed-by: alanb, igerasim, rhalade, mullan
author igerasim
date Wed, 08 Aug 2018 00:32:07 -0700
parents e222c45022e7
children 068a57a8bd8c
files src/share/classes/java/util/jar/JarFile.java src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java src/share/classes/java/util/jar/Manifest.java src/share/classes/sun/misc/JavaUtilJarAccess.java src/share/classes/sun/misc/URLClassPath.java
diffstat 5 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/jar/JarFile.java	Sat Aug 04 12:38:00 2018 +0100
+++ b/src/share/classes/java/util/jar/JarFile.java	Wed Aug 08 00:32:07 2018 -0700
@@ -602,7 +602,7 @@
         return false;
     }
 
-    private synchronized void ensureInitialization() {
+    synchronized void ensureInitialization() {
         try {
             maybeInstantiateVerifier();
         } catch (IOException e) {
--- a/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java	Sat Aug 04 12:38:00 2018 +0100
+++ b/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java	Wed Aug 08 00:32:07 2018 -0700
@@ -65,4 +65,7 @@
         return man.getTrustedAttributes(name);
     }
 
+    public void ensureInitialization(JarFile jar) {
+        jar.ensureInitialization();
+    }
 }
--- a/src/share/classes/java/util/jar/Manifest.java	Sat Aug 04 12:38:00 2018 +0100
+++ b/src/share/classes/java/util/jar/Manifest.java	Wed Aug 08 00:32:07 2018 -0700
@@ -150,6 +150,10 @@
      *      does not exist in SF files of all signers).
      */
     Attributes getTrustedAttributes(String name) {
+        // Note: Before the verification of MANIFEST.MF/.SF/.RSA files is done,
+        // jv.isTrustedManifestEntry() isn't able to detect MANIFEST.MF change.
+        // Users of this method should call SharedSecrets.javaUtilJarAccess()
+        // .ensureInitialization() first.
         Attributes result = getAttributes(name);
         if (result != null && jv != null && ! jv.isTrustedManifestEntry(name)) {
             throw new SecurityException("Untrusted manifest entry: " + name);
--- a/src/share/classes/sun/misc/JavaUtilJarAccess.java	Sat Aug 04 12:38:00 2018 +0100
+++ b/src/share/classes/sun/misc/JavaUtilJarAccess.java	Wed Aug 08 00:32:07 2018 -0700
@@ -44,4 +44,5 @@
     public void setEagerValidation(JarFile jar, boolean eager);
     public List<Object> getManifestDigests(JarFile jar);
     public Attributes getTrustedAttributes(Manifest man, String name);
+    public void ensureInitialization(JarFile jar);
 }
--- a/src/share/classes/sun/misc/URLClassPath.java	Sat Aug 04 12:38:00 2018 +0100
+++ b/src/share/classes/sun/misc/URLClassPath.java	Wed Aug 08 00:32:07 2018 -0700
@@ -987,8 +987,10 @@
                     { return jar.getInputStream(entry); }
                 public int getContentLength()
                     { return (int)entry.getSize(); }
-                public Manifest getManifest() throws IOException
-                    { return jar.getManifest(); };
+                public Manifest getManifest() throws IOException {
+                    SharedSecrets.javaUtilJarAccess().ensureInitialization(jar);
+                    return jar.getManifest();
+                }
                 public Certificate[] getCertificates()
                     { return entry.getCertificates(); };
                 public CodeSigner[] getCodeSigners()