Skip to content

Commit 1a7f2e2

Browse files
authored
Merge pull request #645 from ibmruntimes/openj9-staging
Merge jdk8u362-b09 to 0.36
2 parents 1a94e30 + 841292b commit 1a7f2e2

File tree

26 files changed

+274
-205
lines changed

26 files changed

+274
-205
lines changed

closed/openjdk-tag.gmk

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
OPENJDK_TAG := jdk8u362-b07
1+
OPENJDK_TAG := jdk8u362-b09

corba/src/share/classes/com/sun/corba/se/impl/orbutil/ORBConstants.java

+2
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ public static int makePersistent( int scid )
317317
public static final String DYNAMIC_STUB_FACTORY_FACTORY_CLASS =
318318
SUN_PREFIX + "ORBDynamicStubFactoryFactoryClass" ;
319319

320+
public static final String ALLOW_DESERIALIZE_OBJECT = SUN_PREFIX + "ORBAllowDeserializeObject" ;
321+
320322
// Constants for NameService properties ************************************
321323

322324
public static final int DEFAULT_INITIAL_PORT = 900;

corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/Stub.java

+5
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,11 @@ protected void writeSerializationMethods ()
342342
stream.println (" private void readObject (java.io.ObjectInputStream s) throws java.io.IOException");
343343
stream.println (" {");
344344
stream.println (" String str = s.readUTF ();");
345+
if ("DynAnyFactory".equals (i.name ())) {
346+
stream.println (" if (!str.startsWith(com.sun.corba.se.impl.orbutil.ORBConstants.STRINGIFY_PREFIX) &&");
347+
stream.println (" !Boolean.getBoolean(com.sun.corba.se.impl.orbutil.ORBConstants.ALLOW_DESERIALIZE_OBJECT))");
348+
stream.println (" throw new java.io.InvalidObjectException(\"IOR: expected\");");
349+
}
345350
stream.println (" String[] args = null;");
346351
stream.println (" java.util.Properties props = null;");
347352
stream.println (" org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props);");

jdk/src/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java

+22-42
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
import sun.security.provider.ParameterCache;
3636
import static sun.security.util.SecurityProviderConstants.DEF_DH_KEY_SIZE;
37+
import static sun.security.util.SecurityProviderConstants.getDefDHPrivateExpSize;
3738

3839
/**
3940
* This class represents the key pair generator for Diffie-Hellman key pairs.
@@ -60,9 +61,6 @@ public final class DHKeyPairGenerator extends KeyPairGeneratorSpi {
6061
// The size in bits of the prime modulus
6162
private int pSize;
6263

63-
// The size in bits of the random exponent (private value)
64-
private int lSize;
65-
6664
// The source of randomness
6765
private SecureRandom random;
6866

@@ -71,7 +69,8 @@ public DHKeyPairGenerator() {
7169
initialize(DEF_DH_KEY_SIZE, null);
7270
}
7371

74-
private static void checkKeySize(int keysize)
72+
// pkg private; used by DHParameterGenerator class as well
73+
static void checkKeySize(int keysize, int expSize)
7574
throws InvalidParameterException {
7675

7776
if ((keysize < 512) || (keysize > 8192) || ((keysize & 0x3F) != 0)) {
@@ -80,6 +79,13 @@ private static void checkKeySize(int keysize)
8079
"from 512 to 8192 (inclusive). " +
8180
"The specific key size " + keysize + " is not supported");
8281
}
82+
83+
// optional, could be 0 if not specified
84+
if ((expSize < 0) || (expSize > keysize)) {
85+
throw new InvalidParameterException
86+
("Exponent size must be positive and no larger than" +
87+
" modulus size");
88+
}
8389
}
8490

8591
/**
@@ -91,22 +97,17 @@ private static void checkKeySize(int keysize)
9197
* @param random the source of randomness
9298
*/
9399
public void initialize(int keysize, SecureRandom random) {
100+
checkKeySize(keysize, 0);
94101

95-
checkKeySize(keysize);
96-
97-
// Use the built-in parameters (ranging from 512 to 8192)
98-
// when available.
99-
this.params = ParameterCache.getCachedDHParameterSpec(keysize);
100-
101-
// Due to performance issue, only support DH parameters generation
102-
// up to 1024 bits.
103-
if ((this.params == null) && (keysize > 1024)) {
104-
throw new InvalidParameterException(
105-
"Unsupported " + keysize + "-bit DH parameter generation");
102+
try {
103+
// Use the built-in parameters (ranging from 512 to 8192)
104+
// when available.
105+
this.params = ParameterCache.getDHParameterSpec(keysize, random);
106+
} catch (GeneralSecurityException e) {
107+
throw new InvalidParameterException(e.getMessage());
106108
}
107109

108110
this.pSize = keysize;
109-
this.lSize = 0;
110111
this.random = random;
111112
}
112113

@@ -131,22 +132,13 @@ public void initialize(AlgorithmParameterSpec algParams,
131132
("Inappropriate parameter type");
132133
}
133134

134-
params = (DHParameterSpec)algParams;
135+
params = (DHParameterSpec) algParams;
135136
pSize = params.getP().bitLength();
136137
try {
137-
checkKeySize(pSize);
138+
checkKeySize(pSize, params.getL());
138139
} catch (InvalidParameterException ipe) {
139140
throw new InvalidAlgorithmParameterException(ipe.getMessage());
140141
}
141-
142-
// exponent size is optional, could be 0
143-
lSize = params.getL();
144-
145-
// Require exponentSize < primeSize
146-
if ((lSize != 0) && (lSize > pSize)) {
147-
throw new InvalidAlgorithmParameterException
148-
("Exponent size must not be larger than modulus size");
149-
}
150142
this.random = random;
151143
}
152144

@@ -160,24 +152,12 @@ public KeyPair generateKeyPair() {
160152
random = SunJCE.getRandom();
161153
}
162154

163-
if (params == null) {
164-
try {
165-
params = ParameterCache.getDHParameterSpec(pSize, random);
166-
} catch (GeneralSecurityException e) {
167-
// should never happen
168-
throw new ProviderException(e);
169-
}
170-
}
171-
172155
BigInteger p = params.getP();
173156
BigInteger g = params.getG();
174157

175-
if (lSize <= 0) {
176-
lSize = pSize >> 1;
177-
// use an exponent size of (pSize / 2) but at least 384 bits
178-
if (lSize < 384) {
179-
lSize = 384;
180-
}
158+
int lSize = params.getL();
159+
if (lSize == 0) { // not specified; use our own default
160+
lSize = getDefDHPrivateExpSize(params);
181161
}
182162

183163
BigInteger x;

jdk/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2022, 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
@@ -59,16 +59,20 @@ public final class DHParameterGenerator extends AlgorithmParameterGeneratorSpi {
5959
// The source of randomness
6060
private SecureRandom random = null;
6161

62-
private static void checkKeySize(int keysize)
62+
private static void checkSupport(int keysize, int exponentSize)
6363
throws InvalidParameterException {
6464
boolean supported = ((keysize == 2048) || (keysize == 3072) ||
6565
((keysize >= 512) && (keysize <= 1024) && ((keysize & 0x3F) == 0)));
6666

6767
if (!supported) {
6868
throw new InvalidParameterException(
69-
"DH key size must be multiple of 64 and range " +
69+
"Supported DH key size must be multiple of 64 and range " +
7070
"from 512 to 1024 (inclusive), or 2048, 3072. " +
71-
"The specific key size " + keysize + " is not supported");
71+
"The specified key size " + keysize + " is not supported");
72+
}
73+
74+
if (exponentSize != 0) {
75+
DHKeyPairGenerator.checkKeySize(keysize, exponentSize);
7276
}
7377
}
7478

@@ -82,7 +86,8 @@ private static void checkKeySize(int keysize)
8286
*/
8387
@Override
8488
protected void engineInit(int keysize, SecureRandom random) {
85-
checkKeySize(keysize);
89+
checkSupport(keysize, 0);
90+
8691
this.primeSize = keysize;
8792
this.random = random;
8893
}
@@ -107,21 +112,17 @@ protected void engineInit(AlgorithmParameterSpec genParamSpec,
107112
("Inappropriate parameter type");
108113
}
109114

110-
DHGenParameterSpec dhParamSpec = (DHGenParameterSpec)genParamSpec;
111-
primeSize = dhParamSpec.getPrimeSize();
112-
exponentSize = dhParamSpec.getExponentSize();
113-
if ((exponentSize <= 0) || (exponentSize >= primeSize)) {
114-
throw new InvalidAlgorithmParameterException(
115-
"Exponent size (" + exponentSize +
116-
") must be positive and less than modulus size (" +
117-
primeSize + ")");
118-
}
115+
DHGenParameterSpec dhParamSpec = (DHGenParameterSpec) genParamSpec;
116+
int primeSize = dhParamSpec.getPrimeSize();
117+
int exponentSize = dhParamSpec.getExponentSize();
119118
try {
120-
checkKeySize(primeSize);
119+
checkSupport(primeSize, exponentSize);
121120
} catch (InvalidParameterException ipe) {
122121
throw new InvalidAlgorithmParameterException(ipe.getMessage());
123122
}
124123

124+
this.primeSize = primeSize;
125+
this.exponentSize = exponentSize;
125126
this.random = random;
126127
}
127128

jdk/src/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java

+18-73
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2022, 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
@@ -554,25 +554,20 @@ else if (size == 124)
554554

555555
iis.mark();
556556
iis.skipBytes(profileData - size);
557-
byte[] profile = new byte[profileSize];
558-
iis.readFully(profile, 0, profileSize);
557+
byte[] profile = ReaderUtil.
558+
staggeredReadByteStream(iis, profileSize);
559559
iis.reset();
560560

561-
try {
562-
if (metadata.colorSpace == PROFILE_LINKED &&
563-
isLinkedProfileAllowed() &&
564-
!isUncOrDevicePath(profile))
565-
{
566-
String path = new String(profile, "windows-1252");
561+
if (metadata.colorSpace == PROFILE_LINKED &&
562+
isLinkedProfileAllowed())
563+
{
564+
String path = new String(profile, "windows-1252");
567565

568-
colorSpace =
569-
new ICC_ColorSpace(ICC_Profile.getInstance(path));
570-
} else {
571-
colorSpace =
572-
new ICC_ColorSpace(ICC_Profile.getInstance(profile));
573-
}
574-
} catch (Exception e) {
575-
colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
566+
colorSpace =
567+
new ICC_ColorSpace(ICC_Profile.getInstance(path));
568+
} else if (metadata.colorSpace == PROFILE_EMBEDDED) {
569+
colorSpace =
570+
new ICC_ColorSpace(ICC_Profile.getInstance(profile));
576571
}
577572
}
578573

@@ -1825,68 +1820,18 @@ public void sequenceStarted(ImageReader src, int minIndex) {}
18251820
public void readAborted(ImageReader src) {}
18261821
}
18271822

1828-
private static Boolean isLinkedProfileDisabled = null;
1823+
private static Boolean isLinkedProfileAllowed = null;
18291824

18301825
private static boolean isLinkedProfileAllowed() {
1831-
if (isLinkedProfileDisabled == null) {
1826+
if (isLinkedProfileAllowed == null) {
18321827
PrivilegedAction<Boolean> a = new PrivilegedAction<Boolean>() {
18331828
public Boolean run() {
1834-
return Boolean.getBoolean("sun.imageio.plugins.bmp.disableLinkedProfiles");
1829+
return Boolean.
1830+
getBoolean("sun.imageio.bmp.enableLinkedProfiles");
18351831
}
18361832
};
1837-
isLinkedProfileDisabled = AccessController.doPrivileged(a);
1838-
}
1839-
return !isLinkedProfileDisabled;
1840-
}
1841-
1842-
private static Boolean isWindowsPlatform = null;
1843-
1844-
/**
1845-
* Verifies whether the byte array contans a unc path.
1846-
* Non-UNC path examples:
1847-
* c:\path\to\file - simple notation
1848-
* \\?\c:\path\to\file - long notation
1849-
*
1850-
* UNC path examples:
1851-
* \\server\share - a UNC path in simple notation
1852-
* \\?\UNC\server\share - a UNC path in long notation
1853-
* \\.\some\device - a path to device.
1854-
*/
1855-
private static boolean isUncOrDevicePath(byte[] p) {
1856-
if (isWindowsPlatform == null) {
1857-
PrivilegedAction<Boolean> a = new PrivilegedAction<Boolean>() {
1858-
public Boolean run() {
1859-
String osname = System.getProperty("os.name");
1860-
return (osname != null &&
1861-
osname.toLowerCase().startsWith("win"));
1862-
}
1863-
};
1864-
isWindowsPlatform = AccessController.doPrivileged(a);
1865-
}
1866-
1867-
if (!isWindowsPlatform) {
1868-
/* no need for the check on platforms except windows */
1869-
return false;
1870-
}
1871-
1872-
/* normalize prefix of the path */
1873-
if (p[0] == '/') p[0] = '\\';
1874-
if (p[1] == '/') p[1] = '\\';
1875-
if (p[3] == '/') p[3] = '\\';
1876-
1877-
1878-
if ((p[0] == '\\') && (p[1] == '\\')) {
1879-
if ((p[2] == '?') && (p[3] == '\\')) {
1880-
// long path: whether unc or local
1881-
return ((p[4] == 'U' || p[4] == 'u') &&
1882-
(p[5] == 'N' || p[5] == 'n') &&
1883-
(p[6] == 'C' || p[6] == 'c'));
1884-
} else {
1885-
// device path or short unc notation
1886-
return true;
1887-
}
1888-
} else {
1889-
return false;
1833+
isLinkedProfileAllowed = AccessController.doPrivileged(a);
18901834
}
1835+
return isLinkedProfileAllowed;
18911836
}
18921837
}

jdk/src/share/classes/com/sun/media/sound/JARSoundbankReader.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 2022, 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
@@ -32,6 +32,7 @@
3232
import java.net.URL;
3333
import java.net.URLClassLoader;
3434
import java.util.ArrayList;
35+
import java.util.Objects;
3536
import javax.sound.midi.InvalidMidiDataException;
3637
import javax.sound.midi.Soundbank;
3738
import javax.sound.midi.spi.SoundbankReader;
@@ -45,6 +46,13 @@
4546
*/
4647
public final class JARSoundbankReader extends SoundbankReader {
4748

49+
/*
50+
* Name of the system property that enables the Jar soundbank loading
51+
* true if jar sound bank is allowed to be loaded
52+
* default is false
53+
*/
54+
private final static String JAR_SOUNDBANK_ENABLED = "jdk.sound.jarsoundbank";
55+
4856
private static boolean isZIP(URL url) {
4957
boolean ok = false;
5058
try {
@@ -68,8 +76,10 @@ private static boolean isZIP(URL url) {
6876

6977
public Soundbank getSoundbank(URL url)
7078
throws InvalidMidiDataException, IOException {
71-
if (!isZIP(url))
79+
Objects.requireNonNull(url);
80+
if (!Boolean.getBoolean(JAR_SOUNDBANK_ENABLED) || !isZIP(url))
7281
return null;
82+
7383
ArrayList<Soundbank> soundbanks = new ArrayList<Soundbank>();
7484
URLClassLoader ucl = URLClassLoader.newInstance(new URL[]{url});
7585
InputStream stream = ucl.getResourceAsStream(
@@ -117,6 +127,7 @@ public Soundbank getSoundbank(InputStream stream)
117127

118128
public Soundbank getSoundbank(File file)
119129
throws InvalidMidiDataException, IOException {
130+
Objects.requireNonNull(file);
120131
return getSoundbank(file.toURI().toURL());
121132
}
122133
}

0 commit comments

Comments
 (0)