Skip to content

Commit 8fe1323

Browse files
committedJan 28, 2021
8260520: Avoid getting permissions in JarFileFactory when no SecurityManager installed
Reviewed-by: alanb, dfuchs, michaelm, mullan
1 parent ecde52e commit 8fe1323

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed
 

‎src/java.base/unix/classes/sun/net/www/protocol/jar/JarFileFactory.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -123,10 +123,10 @@ private JarFile getCachedJarFile(URL url) {
123123

124124
/* if the JAR file is cached, the permission will always be there */
125125
if (result != null) {
126-
Permission perm = getPermission(result);
127-
if (perm != null) {
128-
SecurityManager sm = System.getSecurityManager();
129-
if (sm != null) {
126+
SecurityManager sm = System.getSecurityManager();
127+
if (sm != null) {
128+
Permission perm = getPermission(result);
129+
if (perm != null) {
130130
try {
131131
sm.checkPermission(perm);
132132
} catch (SecurityException se) {

‎src/java.base/windows/classes/sun/net/www/protocol/jar/JarFileFactory.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -133,10 +133,10 @@ private JarFile getCachedJarFile(URL url) {
133133

134134
/* if the JAR file is cached, the permission will always be there */
135135
if (result != null) {
136-
Permission perm = getPermission(result);
137-
if (perm != null) {
138-
SecurityManager sm = System.getSecurityManager();
139-
if (sm != null) {
136+
SecurityManager sm = System.getSecurityManager();
137+
if (sm != null) {
138+
Permission perm = getPermission(result);
139+
if (perm != null) {
140140
try {
141141
sm.checkPermission(perm);
142142
} catch (SecurityException se) {

0 commit comments

Comments
 (0)
Please sign in to comment.