8344179: SecurityManager cleanup in the ZIP and JAR areas

Reviewed-by: lancea, rriggs, mullan, jpai
This commit is contained in:
Eirik Bjørsnøs 2024-11-15 07:47:11 +00:00
parent 21966942b6
commit 857f68c60f
3 changed files with 5 additions and 17 deletions

View File

@ -28,7 +28,6 @@ package java.util.jar;
import jdk.internal.access.SharedSecrets; import jdk.internal.access.SharedSecrets;
import jdk.internal.access.JavaUtilZipFileAccess; import jdk.internal.access.JavaUtilZipFileAccess;
import jdk.internal.misc.ThreadTracker; import jdk.internal.misc.ThreadTracker;
import sun.security.action.GetPropertyAction;
import sun.security.util.ManifestEntryVerifier; import sun.security.util.ManifestEntryVerifier;
import sun.security.util.SignatureFileVerifier; import sun.security.util.SignatureFileVerifier;
@ -171,7 +170,7 @@ public class JarFile extends ZipFile {
// multi-release jar file versions >= 9 // multi-release jar file versions >= 9
BASE_VERSION = Runtime.Version.parse(Integer.toString(8)); BASE_VERSION = Runtime.Version.parse(Integer.toString(8));
BASE_VERSION_FEATURE = BASE_VERSION.feature(); BASE_VERSION_FEATURE = BASE_VERSION.feature();
String jarVersion = GetPropertyAction.privilegedGetProperty("jdk.util.jar.version"); String jarVersion = System.getProperty("jdk.util.jar.version");
int runtimeVersion = Runtime.version().feature(); int runtimeVersion = Runtime.version().feature();
if (jarVersion != null) { if (jarVersion != null) {
int jarVer = Integer.parseInt(jarVersion); int jarVer = Integer.parseInt(jarVersion);
@ -180,8 +179,8 @@ public class JarFile extends ZipFile {
: Math.max(jarVer, BASE_VERSION_FEATURE); : Math.max(jarVer, BASE_VERSION_FEATURE);
} }
RUNTIME_VERSION = Runtime.Version.parse(Integer.toString(runtimeVersion)); RUNTIME_VERSION = Runtime.Version.parse(Integer.toString(runtimeVersion));
String enableMultiRelease = GetPropertyAction String enableMultiRelease = System.
.privilegedGetProperty("jdk.util.jar.enableMultiRelease", "true"); getProperty("jdk.util.jar.enableMultiRelease", "true");
switch (enableMultiRelease) { switch (enableMultiRelease) {
case "false" -> { case "false" -> {
MULTI_RELEASE_ENABLED = false; MULTI_RELEASE_ENABLED = false;

View File

@ -55,7 +55,6 @@ import jdk.internal.ref.CleanerFactory;
import jdk.internal.vm.annotation.Stable; import jdk.internal.vm.annotation.Stable;
import sun.nio.cs.UTF_8; import sun.nio.cs.UTF_8;
import sun.nio.fs.DefaultFileSystemProvider; import sun.nio.fs.DefaultFileSystemProvider;
import sun.security.action.GetPropertyAction;
import sun.security.util.SignatureFileVerifier; import sun.security.util.SignatureFileVerifier;
import static java.util.zip.ZipConstants64.*; import static java.util.zip.ZipConstants64.*;
@ -193,14 +192,6 @@ public class ZipFile implements ZipConstants, Closeable {
} }
String name = file.getPath(); String name = file.getPath();
file = new File(name); file = new File(name);
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkRead(name);
if ((mode & OPEN_DELETE) != 0) {
sm.checkDelete(name);
}
}
Objects.requireNonNull(charset, "charset"); Objects.requireNonNull(charset, "charset");
this.filePath = name; this.filePath = name;
@ -1059,8 +1050,7 @@ public class ZipFile implements ZipConstants, Closeable {
*/ */
static boolean getDisableZip64ExtraFieldValidation() { static boolean getDisableZip64ExtraFieldValidation() {
boolean result; boolean result;
String value = GetPropertyAction.privilegedGetProperty( String value = System.getProperty("jdk.util.zip.disableZip64ExtraFieldValidation");
"jdk.util.zip.disableZip64ExtraFieldValidation");
if (value == null) { if (value == null) {
result = false; result = false;
} else { } else {

View File

@ -35,7 +35,6 @@ import static java.util.zip.ZipConstants64.*;
import static java.util.zip.ZipEntry.isCENHeaderValid; import static java.util.zip.ZipEntry.isCENHeaderValid;
import static java.util.zip.ZipUtils.*; import static java.util.zip.ZipUtils.*;
import sun.nio.cs.UTF_8; import sun.nio.cs.UTF_8;
import sun.security.action.GetBooleanAction;
/** /**
* This class implements an output stream filter for writing files in the * This class implements an output stream filter for writing files in the
@ -58,7 +57,7 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant
* some in jdk7. * some in jdk7.
*/ */
private static final boolean inhibitZip64 = private static final boolean inhibitZip64 =
GetBooleanAction.privilegedGetProperty("jdk.util.zip.inhibitZip64"); Boolean.getBoolean("jdk.util.zip.inhibitZip64");
private static class XEntry { private static class XEntry {
final ZipEntry entry; final ZipEntry entry;