Skip to content

Commit

Permalink
Merge pull request #645 from ibmruntimes/openj9-staging
Browse files Browse the repository at this point in the history
Merge jdk8u362-b09 to 0.36
  • Loading branch information
JasonFengJ9 committed Jan 18, 2023
2 parents 1a94e30 + 841292b commit 1a7f2e2
Show file tree
Hide file tree
Showing 26 changed files with 274 additions and 205 deletions.
2 changes: 1 addition & 1 deletion closed/openjdk-tag.gmk
Original file line number Diff line number Diff line change
@@ -1 +1 @@
OPENJDK_TAG := jdk8u362-b07
OPENJDK_TAG := jdk8u362-b09
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ public static int makePersistent( int scid )
public static final String DYNAMIC_STUB_FACTORY_FACTORY_CLASS =
SUN_PREFIX + "ORBDynamicStubFactoryFactoryClass" ;

public static final String ALLOW_DESERIALIZE_OBJECT = SUN_PREFIX + "ORBAllowDeserializeObject" ;

// Constants for NameService properties ************************************

public static final int DEFAULT_INITIAL_PORT = 900;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ protected void writeSerializationMethods ()
stream.println (" private void readObject (java.io.ObjectInputStream s) throws java.io.IOException");
stream.println (" {");
stream.println (" String str = s.readUTF ();");
if ("DynAnyFactory".equals (i.name ())) {
stream.println (" if (!str.startsWith(com.sun.corba.se.impl.orbutil.ORBConstants.STRINGIFY_PREFIX) &&");
stream.println (" !Boolean.getBoolean(com.sun.corba.se.impl.orbutil.ORBConstants.ALLOW_DESERIALIZE_OBJECT))");
stream.println (" throw new java.io.InvalidObjectException(\"IOR: expected\");");
}
stream.println (" String[] args = null;");
stream.println (" java.util.Properties props = null;");
stream.println (" org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init (args, props);");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import sun.security.provider.ParameterCache;
import static sun.security.util.SecurityProviderConstants.DEF_DH_KEY_SIZE;
import static sun.security.util.SecurityProviderConstants.getDefDHPrivateExpSize;

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

// The size in bits of the random exponent (private value)
private int lSize;

// The source of randomness
private SecureRandom random;

Expand All @@ -71,7 +69,8 @@ public DHKeyPairGenerator() {
initialize(DEF_DH_KEY_SIZE, null);
}

private static void checkKeySize(int keysize)
// pkg private; used by DHParameterGenerator class as well
static void checkKeySize(int keysize, int expSize)
throws InvalidParameterException {

if ((keysize < 512) || (keysize > 8192) || ((keysize & 0x3F) != 0)) {
Expand All @@ -80,6 +79,13 @@ private static void checkKeySize(int keysize)
"from 512 to 8192 (inclusive). " +
"The specific key size " + keysize + " is not supported");
}

// optional, could be 0 if not specified
if ((expSize < 0) || (expSize > keysize)) {
throw new InvalidParameterException
("Exponent size must be positive and no larger than" +
" modulus size");
}
}

/**
Expand All @@ -91,22 +97,17 @@ private static void checkKeySize(int keysize)
* @param random the source of randomness
*/
public void initialize(int keysize, SecureRandom random) {
checkKeySize(keysize, 0);

checkKeySize(keysize);

// Use the built-in parameters (ranging from 512 to 8192)
// when available.
this.params = ParameterCache.getCachedDHParameterSpec(keysize);

// Due to performance issue, only support DH parameters generation
// up to 1024 bits.
if ((this.params == null) && (keysize > 1024)) {
throw new InvalidParameterException(
"Unsupported " + keysize + "-bit DH parameter generation");
try {
// Use the built-in parameters (ranging from 512 to 8192)
// when available.
this.params = ParameterCache.getDHParameterSpec(keysize, random);
} catch (GeneralSecurityException e) {
throw new InvalidParameterException(e.getMessage());
}

this.pSize = keysize;
this.lSize = 0;
this.random = random;
}

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

params = (DHParameterSpec)algParams;
params = (DHParameterSpec) algParams;
pSize = params.getP().bitLength();
try {
checkKeySize(pSize);
checkKeySize(pSize, params.getL());
} catch (InvalidParameterException ipe) {
throw new InvalidAlgorithmParameterException(ipe.getMessage());
}

// exponent size is optional, could be 0
lSize = params.getL();

// Require exponentSize < primeSize
if ((lSize != 0) && (lSize > pSize)) {
throw new InvalidAlgorithmParameterException
("Exponent size must not be larger than modulus size");
}
this.random = random;
}

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

if (params == null) {
try {
params = ParameterCache.getDHParameterSpec(pSize, random);
} catch (GeneralSecurityException e) {
// should never happen
throw new ProviderException(e);
}
}

BigInteger p = params.getP();
BigInteger g = params.getG();

if (lSize <= 0) {
lSize = pSize >> 1;
// use an exponent size of (pSize / 2) but at least 384 bits
if (lSize < 384) {
lSize = 384;
}
int lSize = params.getL();
if (lSize == 0) { // not specified; use our own default
lSize = getDefDHPrivateExpSize(params);
}

BigInteger x;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -59,16 +59,20 @@ public final class DHParameterGenerator extends AlgorithmParameterGeneratorSpi {
// The source of randomness
private SecureRandom random = null;

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

if (!supported) {
throw new InvalidParameterException(
"DH key size must be multiple of 64 and range " +
"Supported DH key size must be multiple of 64 and range " +
"from 512 to 1024 (inclusive), or 2048, 3072. " +
"The specific key size " + keysize + " is not supported");
"The specified key size " + keysize + " is not supported");
}

if (exponentSize != 0) {
DHKeyPairGenerator.checkKeySize(keysize, exponentSize);
}
}

Expand All @@ -82,7 +86,8 @@ private static void checkKeySize(int keysize)
*/
@Override
protected void engineInit(int keysize, SecureRandom random) {
checkKeySize(keysize);
checkSupport(keysize, 0);

this.primeSize = keysize;
this.random = random;
}
Expand All @@ -107,21 +112,17 @@ protected void engineInit(AlgorithmParameterSpec genParamSpec,
("Inappropriate parameter type");
}

DHGenParameterSpec dhParamSpec = (DHGenParameterSpec)genParamSpec;
primeSize = dhParamSpec.getPrimeSize();
exponentSize = dhParamSpec.getExponentSize();
if ((exponentSize <= 0) || (exponentSize >= primeSize)) {
throw new InvalidAlgorithmParameterException(
"Exponent size (" + exponentSize +
") must be positive and less than modulus size (" +
primeSize + ")");
}
DHGenParameterSpec dhParamSpec = (DHGenParameterSpec) genParamSpec;
int primeSize = dhParamSpec.getPrimeSize();
int exponentSize = dhParamSpec.getExponentSize();
try {
checkKeySize(primeSize);
checkSupport(primeSize, exponentSize);
} catch (InvalidParameterException ipe) {
throw new InvalidAlgorithmParameterException(ipe.getMessage());
}

this.primeSize = primeSize;
this.exponentSize = exponentSize;
this.random = random;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -554,25 +554,20 @@ else if (size == 124)

iis.mark();
iis.skipBytes(profileData - size);
byte[] profile = new byte[profileSize];
iis.readFully(profile, 0, profileSize);
byte[] profile = ReaderUtil.
staggeredReadByteStream(iis, profileSize);
iis.reset();

try {
if (metadata.colorSpace == PROFILE_LINKED &&
isLinkedProfileAllowed() &&
!isUncOrDevicePath(profile))
{
String path = new String(profile, "windows-1252");
if (metadata.colorSpace == PROFILE_LINKED &&
isLinkedProfileAllowed())
{
String path = new String(profile, "windows-1252");

colorSpace =
new ICC_ColorSpace(ICC_Profile.getInstance(path));
} else {
colorSpace =
new ICC_ColorSpace(ICC_Profile.getInstance(profile));
}
} catch (Exception e) {
colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
colorSpace =
new ICC_ColorSpace(ICC_Profile.getInstance(path));
} else if (metadata.colorSpace == PROFILE_EMBEDDED) {
colorSpace =
new ICC_ColorSpace(ICC_Profile.getInstance(profile));
}
}

Expand Down Expand Up @@ -1825,68 +1820,18 @@ public void sequenceStarted(ImageReader src, int minIndex) {}
public void readAborted(ImageReader src) {}
}

private static Boolean isLinkedProfileDisabled = null;
private static Boolean isLinkedProfileAllowed = null;

private static boolean isLinkedProfileAllowed() {
if (isLinkedProfileDisabled == null) {
if (isLinkedProfileAllowed == null) {
PrivilegedAction<Boolean> a = new PrivilegedAction<Boolean>() {
public Boolean run() {
return Boolean.getBoolean("sun.imageio.plugins.bmp.disableLinkedProfiles");
return Boolean.
getBoolean("sun.imageio.bmp.enableLinkedProfiles");
}
};
isLinkedProfileDisabled = AccessController.doPrivileged(a);
}
return !isLinkedProfileDisabled;
}

private static Boolean isWindowsPlatform = null;

/**
* Verifies whether the byte array contans a unc path.
* Non-UNC path examples:
* c:\path\to\file - simple notation
* \\?\c:\path\to\file - long notation
*
* UNC path examples:
* \\server\share - a UNC path in simple notation
* \\?\UNC\server\share - a UNC path in long notation
* \\.\some\device - a path to device.
*/
private static boolean isUncOrDevicePath(byte[] p) {
if (isWindowsPlatform == null) {
PrivilegedAction<Boolean> a = new PrivilegedAction<Boolean>() {
public Boolean run() {
String osname = System.getProperty("os.name");
return (osname != null &&
osname.toLowerCase().startsWith("win"));
}
};
isWindowsPlatform = AccessController.doPrivileged(a);
}

if (!isWindowsPlatform) {
/* no need for the check on platforms except windows */
return false;
}

/* normalize prefix of the path */
if (p[0] == '/') p[0] = '\\';
if (p[1] == '/') p[1] = '\\';
if (p[3] == '/') p[3] = '\\';


if ((p[0] == '\\') && (p[1] == '\\')) {
if ((p[2] == '?') && (p[3] == '\\')) {
// long path: whether unc or local
return ((p[4] == 'U' || p[4] == 'u') &&
(p[5] == 'N' || p[5] == 'n') &&
(p[6] == 'C' || p[6] == 'c'));
} else {
// device path or short unc notation
return true;
}
} else {
return false;
isLinkedProfileAllowed = AccessController.doPrivileged(a);
}
return isLinkedProfileAllowed;
}
}
15 changes: 13 additions & 2 deletions jdk/src/share/classes/com/sun/media/sound/JARSoundbankReader.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -32,6 +32,7 @@
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Objects;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.Soundbank;
import javax.sound.midi.spi.SoundbankReader;
Expand All @@ -45,6 +46,13 @@
*/
public final class JARSoundbankReader extends SoundbankReader {

/*
* Name of the system property that enables the Jar soundbank loading
* true if jar sound bank is allowed to be loaded
* default is false
*/
private final static String JAR_SOUNDBANK_ENABLED = "jdk.sound.jarsoundbank";

private static boolean isZIP(URL url) {
boolean ok = false;
try {
Expand All @@ -68,8 +76,10 @@ private static boolean isZIP(URL url) {

public Soundbank getSoundbank(URL url)
throws InvalidMidiDataException, IOException {
if (!isZIP(url))
Objects.requireNonNull(url);
if (!Boolean.getBoolean(JAR_SOUNDBANK_ENABLED) || !isZIP(url))
return null;

ArrayList<Soundbank> soundbanks = new ArrayList<Soundbank>();
URLClassLoader ucl = URLClassLoader.newInstance(new URL[]{url});
InputStream stream = ucl.getResourceAsStream(
Expand Down Expand Up @@ -117,6 +127,7 @@ public Soundbank getSoundbank(InputStream stream)

public Soundbank getSoundbank(File file)
throws InvalidMidiDataException, IOException {
Objects.requireNonNull(file);
return getSoundbank(file.toURI().toURL());
}
}
Loading

0 comments on commit 1a7f2e2

Please sign in to comment.