diff --git a/src/share/classes/java/util/jar/JarFile.java b/src/share/classes/java/util/jar/JarFile.java index e68b92b6aab0d15db162beac717d25309ec20e4c..940dfb679a4112b0dbfffd0fb44dd93706e437b9 100644 --- a/src/share/classes/java/util/jar/JarFile.java +++ b/src/share/classes/java/util/jar/JarFile.java @@ -602,7 +602,7 @@ class JarFile extends ZipFile { return false; } - private synchronized void ensureInitialization() { + synchronized void ensureInitialization() { try { maybeInstantiateVerifier(); } catch (IOException e) { diff --git a/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java b/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java index aca00dbcb8ecc14eddb7da1db94c39acf705b4c1..f1f132d56c563c6cf81f179ef4d18f60d1e9badd 100644 --- a/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java +++ b/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java @@ -65,4 +65,7 @@ class JavaUtilJarAccessImpl implements JavaUtilJarAccess { return man.getTrustedAttributes(name); } + public void ensureInitialization(JarFile jar) { + jar.ensureInitialization(); + } } diff --git a/src/share/classes/java/util/jar/Manifest.java b/src/share/classes/java/util/jar/Manifest.java index 66310d15ea48d914f072f3ee45269574a59d1f88..75434eb9511cc57f74a2a38ae251a22e294d45c8 100644 --- a/src/share/classes/java/util/jar/Manifest.java +++ b/src/share/classes/java/util/jar/Manifest.java @@ -150,6 +150,10 @@ public class Manifest implements Cloneable { * 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); diff --git a/src/share/classes/sun/misc/JavaUtilJarAccess.java b/src/share/classes/sun/misc/JavaUtilJarAccess.java index 1d2e4ea861126d617d9939e9d90a6389f30ba267..01ae4d5a425c7e29ddaa8f9460440b667aec8cfd 100644 --- a/src/share/classes/sun/misc/JavaUtilJarAccess.java +++ b/src/share/classes/sun/misc/JavaUtilJarAccess.java @@ -44,4 +44,5 @@ public interface JavaUtilJarAccess { public void setEagerValidation(JarFile jar, boolean eager); public List getManifestDigests(JarFile jar); public Attributes getTrustedAttributes(Manifest man, String name); + public void ensureInitialization(JarFile jar); } diff --git a/src/share/classes/sun/misc/URLClassPath.java b/src/share/classes/sun/misc/URLClassPath.java index e47d3f97cd299d9a838fcd4e6035f54902decc8e..b7d8594a94714e3b8aa83887a9864dc8004e3112 100644 --- a/src/share/classes/sun/misc/URLClassPath.java +++ b/src/share/classes/sun/misc/URLClassPath.java @@ -987,8 +987,10 @@ public class URLClassPath { { 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()