Skip to content

Commit

Permalink
Merge pull request #680 from ibmruntimes/openj9-staging
Browse files Browse the repository at this point in the history
Merge jdk8u382-b05 into 0.40.0 release
  • Loading branch information
JasonFengJ9 authored Jul 20, 2023
2 parents 347f96b + 4fbae6f commit 1f8c2ec
Show file tree
Hide file tree
Showing 19 changed files with 1,100 additions and 148 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 := jdk8u382-b04
OPENJDK_TAG := jdk8u382-b05
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ void PORT_GetControls(void* id, INT32 portIndex, PortControlCreator* creator) {
CFRelease(cfname);
} else {
channelName = (char *)malloc(16);
sprintf(channelName, "Ch %d", ch);
snprintf(channelName, 16, "Ch %d", ch);
}

void* jControls[2];
Expand Down
2 changes: 1 addition & 1 deletion jdk/src/macosx/native/sun/font/AWTStrike.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ + (AWTStrike *) awtStrikeForFont:(AWTFont *)awtFont
#define AWT_FONT_CLEANUP_FINISH \
if (_fontThrowJavaException == YES) { \
char s[512]; \
sprintf(s, "%s-%s:%d", THIS_FILE, __FUNCTION__, __LINE__); \
snprintf(s, sizeof(s), "%s-%s:%d", THIS_FILE, __FUNCTION__, __LINE__); \
[JNFException raise:env as:kRuntimeException reason:s]; \
}

Expand Down
71 changes: 52 additions & 19 deletions jdk/src/share/classes/com/sun/crypto/provider/CipherCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2018, 2022 All Rights Reserved
* (c) Copyright IBM Corp. 2018, 2023 All Rights Reserved
* ===========================================================================
*/

Expand Down Expand Up @@ -892,12 +892,26 @@ byte[] doFinal(byte[] input, int inputOffset, int inputLen)
try {
checkReinit();
byte[] output = new byte[getOutputSizeByOperation(inputLen, true)];
byte[] finalBuf = prepareInputBuffer(input, inputOffset,
inputLen, output, 0);
int outputOffset = 0;
int outLen = 0;

if (inputLen > 0) {
/*
* Call the update() method to get rid of as many bytes as
* possible before potentially copying array.
*/
int updateOutLen = update(input, inputOffset, inputLen, output, outputOffset);
inputOffset = inputLen;
inputLen = 0;
outputOffset += updateOutLen;
outLen = updateOutLen;
}

byte[] finalBuf = prepareInputBuffer(input, inputOffset, inputLen, output, outputOffset);
int finalOffset = (finalBuf == input) ? inputOffset : 0;
int finalBufLen = (finalBuf == input) ? inputLen : finalBuf.length;

int outLen = fillOutputBuffer(finalBuf, finalOffset, output, 0,
outLen += fillOutputBuffer(finalBuf, finalOffset, output, outputOffset,
finalBufLen, input);

endDoFinal();
Expand Down Expand Up @@ -962,13 +976,6 @@ int doFinal(byte[] input, int inputOffset, int inputLen, byte[] output,
int estOutSize = getOutputSizeByOperation(inputLen, true);
int outputCapacity = checkOutputCapacity(output, outputOffset,
estOutSize);
int offset = decrypting ? 0 : outputOffset; // 0 for decrypting
byte[] finalBuf = prepareInputBuffer(input, inputOffset,
inputLen, output, outputOffset);
byte[] outWithPadding = null; // for decrypting only

int finalOffset = (finalBuf == input) ? inputOffset : 0;
int finalBufLen = (finalBuf == input) ? inputLen : finalBuf.length;

if (decrypting) {
// if the size of specified output buffer is less than
Expand All @@ -979,14 +986,41 @@ int doFinal(byte[] input, int inputOffset, int inputLen, byte[] output,
if (outputCapacity < estOutSize) {
cipher.save();
}
}

int outLen = 0;
int estFinalBuffSize = estOutSize;
if (inputLen > 0) {
/*
* Call the update() method to get rid of as many bytes as
* possible before potentially copying array.
*/
int updateOutLen = update(input, inputOffset, inputLen, output, outputOffset);
inputOffset = inputLen;
inputLen = 0;
outputOffset += updateOutLen;
outLen += updateOutLen;
estFinalBuffSize -= updateOutLen;
}

int offset = decrypting ? 0 : outputOffset; // 0 for decrypting
byte[] finalBuf = prepareInputBuffer(input, inputOffset,
inputLen, output, outputOffset);
byte[] outWithPadding = null; // for decrypting only

int finalOffset = (finalBuf == input) ? inputOffset : 0;
int finalBufLen = (finalBuf == input) ? inputLen : finalBuf.length;

if (decrypting) {
// create temporary output buffer so that only "real"
// data bytes are passed to user's output buffer.
outWithPadding = new byte[estOutSize];
outWithPadding = new byte[estFinalBuffSize];
}
byte[] outBuffer = decrypting ? outWithPadding : output;

int outLen = fillOutputBuffer(finalBuf, finalOffset, outBuffer,
int outBuffLen = fillOutputBuffer(finalBuf, finalOffset, outBuffer,
offset, finalBufLen, input);
outLen += outBuffLen;

if (decrypting) {

Expand All @@ -999,7 +1033,7 @@ int doFinal(byte[] input, int inputOffset, int inputLen, byte[] output,
+ " bytes needed");
}
// copy the result into user-supplied output buffer
System.arraycopy(outWithPadding, 0, output, outputOffset, outLen);
System.arraycopy(outWithPadding, 0, output, outputOffset, outBuffLen);
// decrypt mode. Zero out output data that's not required
Arrays.fill(outWithPadding, (byte) 0x00);
}
Expand All @@ -1015,16 +1049,15 @@ private void endDoFinal() {
}
}

private int unpad(int outLen, byte[] outWithPadding)
private int unpad(int outLen, int off, byte[] outWithPadding)
throws BadPaddingException {
int padStart = padding.unpad(outWithPadding, 0, outLen);
int padStart = padding.unpad(outWithPadding, off, outLen);
if (padStart < 0) {
throw new BadPaddingException("Given final block not " +
"properly padded. Such issues can arise if a bad key " +
"is used during decryption.");
}
outLen = padStart;
return outLen;
return padStart - off;
}

private byte[] prepareInputBuffer(byte[] input, int inputOffset,
Expand Down Expand Up @@ -1100,7 +1133,7 @@ private int fillOutputBuffer(byte[] finalBuf, int finalOffset,
len = finalNoPadding(finalBuf, finalOffset, output,
outOfs, finalBufLen);
if (decrypting && padding != null) {
len = unpad(len, output);
len = unpad(len, outOfs, output);
}
return len;
} finally {
Expand Down
11 changes: 6 additions & 5 deletions jdk/src/share/classes/java/util/jar/JarFile.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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 @@ -74,8 +74,6 @@ class JarFile extends ZipFile {
private JarVerifier jv;
private boolean jvInitialized;
private boolean verify;
// The maximum size of array to allocate. Some VMs reserve some header words in an array.
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;

// indicates if Class-Path attribute present (only valid if hasCheckedSpecialAttributes true)
private boolean hasClassPathAttribute;
Expand Down Expand Up @@ -434,8 +432,11 @@ private void initializeVerifier() {
private byte[] getBytes(ZipEntry ze) throws IOException {
try (InputStream is = super.getInputStream(ze)) {
long uncompressedSize = ze.getSize();
if (uncompressedSize > MAX_ARRAY_SIZE) {
throw new IOException("Unsupported size: " + uncompressedSize);
if (uncompressedSize > SignatureFileVerifier.MAX_SIG_FILE_SIZE) {
throw new IOException("Unsupported size: " + uncompressedSize +
" for JarEntry " + ze.getName() +
". Allowed max size: " +
SignatureFileVerifier.MAX_SIG_FILE_SIZE + " bytes");
}
int len = (int)uncompressedSize;
byte[] b = IOUtils.readAllBytes(is);
Expand Down
12 changes: 12 additions & 0 deletions jdk/src/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,18 @@ public void load(InputStream input, Class<?> resourceBase) throws
* <code>new URL(synthFile, path)</code>. Refer to
* <a href="doc-files/synthFileFormat.html">Synth File Format</a> for more
* information.
* <p>
* Whilst this API may be safe for loading local resources that are
* delivered with a {@code LookAndFeel} or application, and so have an
* equal level of trust with application code, using it to load from
* remote resources, particularly any which may have a lower level of
* trust, is strongly discouraged.
* The alternative mechanisms to load styles from an {@code InputStream}
* {@linkplain #load(InputStream, Class)}
* using resources co-located with the application or by providing a
* {@code SynthStyleFactory} to
* {@linkplain #setStyleFactory setStyleFactory(SynthStyleFactory)}
* are preferred.
*
* @param url the <code>URL</code> to load the set of
* <code>SynthStyle</code> from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ <h2><a name="file">File Format</a></h2>
<p>
This example loads the look and feel from an input stream, using
the specified class as the resource base to resolve paths.
</p>
<p>
It is also possible to load a look and feel from an arbitrary URL
as in the following example.
</p>
Expand All @@ -62,6 +64,11 @@ <h2><a name="file">File Format</a></h2>
<li>Remote JAR file, e.g.
<code>jar:http://host/synth-laf.jar!/laf.xml</code></li>
</ul>
<p>Note: Synth's file format allows for the definition of code to be executed.
Loading any code from a remote location should be used only
with extreme caution from a trusted source over a secure connection.
It is strongly discouraged for an application or a LookAndFeel to do so.
</p>
<p>
While the DTD for synth is specified, the parser is not validating.
Parsing will fail only if a necessary attribute is not
Expand Down
2 changes: 0 additions & 2 deletions jdk/src/share/classes/sun/nio/cs/AbstractCharsetProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@
import java.util.ArrayList;
import java.util.TreeMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import sun.misc.ASCIICaseInsensitiveComparator;


/**
* Abstract base class for charset providers.
*
Expand Down
50 changes: 39 additions & 11 deletions jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2023, 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 All @@ -25,11 +25,9 @@

package sun.nio.cs.ext;

import java.lang.ref.SoftReference;
import java.nio.charset.Charset;
import java.nio.charset.spi.CharsetProvider;
import sun.nio.cs.AbstractCharsetProvider;
import java.security.AccessController;

import sun.security.action.GetPropertyAction;


Expand Down Expand Up @@ -115,9 +113,11 @@ public ExtendedCharsets() {
"CP936"
});

// The definition of this charset may be overridden by the init method
// below, if the jdk.charset.GB18030 property is set
charset("GB18030", "GB18030",
new String[] {
"gb18030-2000"
"gb18030-2022"
});

charset("GB2312", "EUC_CN",
Expand Down Expand Up @@ -1136,14 +1136,15 @@ public ExtendedCharsets() {
}

private boolean initialized = false;
private boolean isGB18030_2000 = false;

// If the sun.nio.cs.map property is defined on the command line we won't
// see it in the system-properties table until after the charset subsystem
// has been initialized. We therefore delay the effect of this property
// until after the JRE has completely booted.
// If the sun.nio.cs.map and/or jdk.charset.GB18030 properties are defined
// on the command line we won't see them in the system-properties table until
// after the charset subsystem has been initialized. We therefore delay
// the effect of these property until after the JRE has completely booted.
//
// At the moment following values for this property are supported, property
// value string is case insensitive.
// At the moment the following values for the sun.nio.cs.map property are
// supported and the property value string is case insensitive.
//
// (1)"Windows-31J/Shift_JIS"
// In 1.4.1 we added a correct implementation of the Shift_JIS charset
Expand Down Expand Up @@ -1176,6 +1177,10 @@ public ExtendedCharsets() {
// where each charset named to the left of a slash is intended to replace
// (most) uses of the charset named to the right of the slash.
//
// The jdk.charset.GB18030 property is simpler and accepts only the value
// "2000". If this value is given, the older GB18030-2000 variant of the
// character set replaces the default GB18030-2022 variant.
//
protected void init() {
if (initialized)
return;
Expand All @@ -1184,6 +1189,8 @@ protected void init() {

String map = AccessController.doPrivileged(
new GetPropertyAction("sun.nio.cs.map"));
boolean isGB18030_2000 = "2000".equals(AccessController.doPrivileged(
new GetPropertyAction("jdk.charset.GB18030")));
boolean sjisIsMS932 = false;
boolean iso2022jpIsMS50221 = false;
boolean iso2022jpIsMS50220 = false;
Expand All @@ -1202,6 +1209,16 @@ protected void init() {
}
}
}
if (isGB18030_2000) {
deleteCharset("GB18030",
new String[] {
"gb18030-2022"
});
charset("GB18030", "GB18030",
new String[] {
"gb18030-2000"
});
}
if (sjisIsMS932) {
deleteCharset("Shift_JIS",
new String[] {
Expand Down Expand Up @@ -1314,6 +1331,7 @@ protected void init() {
"x-compound-text"
});
}
this.isGB18030_2000 = isGB18030_2000;
initialized = true;
}

Expand All @@ -1322,4 +1340,14 @@ public static String[] aliasesFor(String charsetName) {
return null;
return instance.aliases(charsetName);
}

static boolean IS_2000() {
if (instance == null) {
return false;
}
if (!instance.initialized) {
instance.init();
}
return instance.isGB18030_2000;
}
}
Loading

0 comments on commit 1f8c2ec

Please sign in to comment.