Skip to content

Commit e73db06

Browse files
authored
Merge pull request #153 from pshipton/0.35
Merge jdk-17.0.5+8 into 0.35
2 parents 43dee90 + 552d823 commit e73db06

File tree

35 files changed

+934
-301
lines changed

35 files changed

+934
-301
lines changed

closed/openjdk-tag.gmk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
OPENJDK_TAG := jdk-17.0.5+7
1+
OPENJDK_TAG := jdk-17.0.5+8

make/common/modules/LauncherCommon.gmk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ endif
4747

4848
LAUNCHER_SRC := $(TOPDIR)/src/java.base/share/native/launcher
4949
LAUNCHER_CFLAGS += -I$(TOPDIR)/src/java.base/share/native/launcher \
50+
-I$(TOPDIR)/src/java.desktop/share/native/include \
5051
-I$(TOPDIR)/src/java.base/share/native/libjli \
5152
-I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjli \
5253
-I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libjli \

make/conf/version-numbers.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ DEFAULT_VERSION_CLASSFILE_MINOR=0
3939
DEFAULT_VERSION_DOCS_API_SINCE=11
4040
DEFAULT_ACCEPTABLE_BOOT_VERSIONS="16 17"
4141
DEFAULT_JDK_SOURCE_TARGET_VERSION=17
42-
DEFAULT_PROMOTED_VERSION_PRE=ea
42+
DEFAULT_PROMOTED_VERSION_PRE=

make/modules/java.desktop/lib/Awt2dLibraries.gmk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ ifeq ($(call isTargetOs, windows macosx), false)
368368
common/awt/debug \
369369
common/font \
370370
common/java2d/opengl \
371+
include \
371372
#
372373

373374
LIBAWT_HEADLESS_CFLAGS := $(CUPS_CFLAGS) $(FONTCONFIG_CFLAGS) $(X_CFLAGS) \
@@ -477,6 +478,7 @@ LIBFONTMANAGER_EXTRA_HEADER_DIRS := \
477478
libawt/java2d \
478479
libawt/java2d/pipe \
479480
libawt/java2d/loops \
481+
include \
480482
#
481483

482484
LIBFONTMANAGER_CFLAGS += $(LIBFREETYPE_CFLAGS)
@@ -656,6 +658,8 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false)
656658
common/awt/systemscale \
657659
#
658660

661+
LIBSPLASHSCREEN_HEADER_DIRS += include
662+
659663
ifeq ($(USE_EXTERNAL_LIBGIF), false)
660664
LIBSPLASHSCREEN_HEADER_DIRS += libsplashscreen/giflib
661665
else

src/java.base/share/classes/com/sun/security/ntlm/Client.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 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
@@ -117,9 +117,10 @@ public byte[] type1() {
117117
* {@code nonce} is null for NTLM v1.
118118
*/
119119
public byte[] type3(byte[] type2, byte[] nonce) throws NTLMException {
120-
if (type2 == null || (v != Version.NTLM && nonce == null)) {
120+
if (type2 == null || (v != Version.NTLM && nonce == null) ||
121+
(nonce != null && nonce.length != 8)) {
121122
throw new NTLMException(NTLMException.PROTOCOL,
122-
"type2 and nonce cannot be null");
123+
"type2 cannot be null, and nonce must be 8-byte long");
123124
}
124125
debug("NTLM Client: Type 2 received\n");
125126
debug(type2);

src/java.base/share/classes/com/sun/security/ntlm/NTLM.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,23 +226,27 @@ void writeBytes(int offset, byte[] data) {
226226
System.arraycopy(data, 0, internal, offset, data.length);
227227
}
228228

229-
void writeSecurityBuffer(int offset, byte[] data) {
229+
void writeSecurityBuffer(int offset, byte[] data) throws NTLMException {
230230
if (data == null) {
231-
writeShort(offset+4, current);
231+
writeInt(offset+4, current);
232232
} else {
233233
int len = data.length;
234+
if (len > 65535) {
235+
throw new NTLMException(NTLMException.INVALID_INPUT,
236+
"Invalid data length " + len);
237+
}
234238
if (current + len > internal.length) {
235239
internal = Arrays.copyOf(internal, current + len + 256);
236240
}
237241
writeShort(offset, len);
238242
writeShort(offset+2, len);
239-
writeShort(offset+4, current);
243+
writeInt(offset+4, current);
240244
System.arraycopy(data, 0, internal, current, len);
241245
current += len;
242246
}
243247
}
244248

245-
void writeSecurityBuffer(int offset, String str, boolean unicode) {
249+
void writeSecurityBuffer(int offset, String str, boolean unicode) throws NTLMException {
246250
writeSecurityBuffer(offset, str == null ? null : str.getBytes(
247251
unicode ? StandardCharsets.UTF_16LE
248252
: StandardCharsets.ISO_8859_1));

src/java.base/share/classes/com/sun/security/ntlm/NTLMException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ public final class NTLMException extends GeneralSecurityException {
6565
*/
6666
public static final int PROTOCOL = 6;
6767

68+
/**
69+
* If an invalid input is provided.
70+
*/
71+
public static final int INVALID_INPUT = 7;
72+
6873
private int errorCode;
6974

7075
/**

src/java.base/share/classes/com/sun/security/ntlm/Server.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 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
@@ -85,9 +85,9 @@ public Server(String version, String domain) throws NTLMException {
8585
* {@code nonce} is null.
8686
*/
8787
public byte[] type2(byte[] type1, byte[] nonce) throws NTLMException {
88-
if (nonce == null) {
88+
if (nonce == null || nonce.length != 8) {
8989
throw new NTLMException(NTLMException.PROTOCOL,
90-
"nonce cannot be null");
90+
"nonce must be 8-byte long");
9191
}
9292
debug("NTLM Server: Type 1 received\n");
9393
if (type1 != null) debug(type1);

src/java.base/share/classes/java/math/BigDecimal.java

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131

3232
import static java.math.BigInteger.LONG_MASK;
3333
import java.io.IOException;
34+
import java.io.InvalidObjectException;
35+
import java.io.ObjectInputStream;
36+
import java.io.ObjectStreamException;
37+
import java.io.StreamCorruptedException;
3438
import java.util.Arrays;
3539
import java.util.Objects;
3640

@@ -1058,6 +1062,15 @@ public BigDecimal(double val, MathContext mc) {
10581062
this.precision = prec;
10591063
}
10601064

1065+
/**
1066+
* Accept no subclasses.
1067+
*/
1068+
private static BigInteger toStrictBigInteger(BigInteger val) {
1069+
return (val.getClass() == BigInteger.class) ?
1070+
val :
1071+
new BigInteger(val.toByteArray().clone());
1072+
}
1073+
10611074
/**
10621075
* Translates a {@code BigInteger} into a {@code BigDecimal}.
10631076
* The scale of the {@code BigDecimal} is zero.
@@ -1067,8 +1080,8 @@ public BigDecimal(double val, MathContext mc) {
10671080
*/
10681081
public BigDecimal(BigInteger val) {
10691082
scale = 0;
1070-
intVal = val;
1071-
intCompact = compactValFor(val);
1083+
intVal = toStrictBigInteger(val);
1084+
intCompact = compactValFor(intVal);
10721085
}
10731086

10741087
/**
@@ -1082,7 +1095,7 @@ public BigDecimal(BigInteger val) {
10821095
* @since 1.5
10831096
*/
10841097
public BigDecimal(BigInteger val, MathContext mc) {
1085-
this(val,0,mc);
1098+
this(toStrictBigInteger(val), 0, mc);
10861099
}
10871100

10881101
/**
@@ -1096,8 +1109,8 @@ public BigDecimal(BigInteger val, MathContext mc) {
10961109
*/
10971110
public BigDecimal(BigInteger unscaledVal, int scale) {
10981111
// Negative scales are now allowed
1099-
this.intVal = unscaledVal;
1100-
this.intCompact = compactValFor(unscaledVal);
1112+
this.intVal = toStrictBigInteger(unscaledVal);
1113+
this.intCompact = compactValFor(this.intVal);
11011114
this.scale = scale;
11021115
}
11031116

@@ -1115,6 +1128,7 @@ public BigDecimal(BigInteger unscaledVal, int scale) {
11151128
* @since 1.5
11161129
*/
11171130
public BigDecimal(BigInteger unscaledVal, int scale, MathContext mc) {
1131+
unscaledVal = toStrictBigInteger(unscaledVal);
11181132
long compactVal = compactValFor(unscaledVal);
11191133
int mcp = mc.precision;
11201134
int prec = 0;
@@ -4257,9 +4271,13 @@ private static class UnsafeHolder {
42574271
= unsafe.objectFieldOffset(BigDecimal.class, "intCompact");
42584272
private static final long intValOffset
42594273
= unsafe.objectFieldOffset(BigDecimal.class, "intVal");
4274+
private static final long scaleOffset
4275+
= unsafe.objectFieldOffset(BigDecimal.class, "scale");
42604276

4261-
static void setIntCompact(BigDecimal bd, long val) {
4262-
unsafe.putLong(bd, intCompactOffset, val);
4277+
static void setIntValAndScale(BigDecimal bd, BigInteger intVal, int scale) {
4278+
unsafe.putReference(bd, intValOffset, intVal);
4279+
unsafe.putInt(bd, scaleOffset, scale);
4280+
unsafe.putLong(bd, intCompactOffset, compactValFor(intVal));
42634281
}
42644282

42654283
static void setIntValVolatile(BigDecimal bd, BigInteger val) {
@@ -4278,15 +4296,30 @@ static void setIntValVolatile(BigDecimal bd, BigInteger val) {
42784296
@java.io.Serial
42794297
private void readObject(java.io.ObjectInputStream s)
42804298
throws IOException, ClassNotFoundException {
4281-
// Read in all fields
4282-
s.defaultReadObject();
4283-
// validate possibly bad fields
4284-
if (intVal == null) {
4285-
String message = "BigDecimal: null intVal in stream";
4286-
throw new java.io.StreamCorruptedException(message);
4287-
// [all values of scale are now allowed]
4299+
// prepare to read the fields
4300+
ObjectInputStream.GetField fields = s.readFields();
4301+
BigInteger serialIntVal = (BigInteger) fields.get("intVal", null);
4302+
4303+
// Validate field data
4304+
if (serialIntVal == null) {
4305+
throw new StreamCorruptedException("Null or missing intVal in BigDecimal stream");
42884306
}
4289-
UnsafeHolder.setIntCompact(this, compactValFor(intVal));
4307+
// Validate provenance of serialIntVal object
4308+
serialIntVal = toStrictBigInteger(serialIntVal);
4309+
4310+
// Any integer value is valid for scale
4311+
int serialScale = fields.get("scale", 0);
4312+
4313+
UnsafeHolder.setIntValAndScale(this, serialIntVal, serialScale);
4314+
}
4315+
4316+
/**
4317+
* Serialization without data not supported for this class.
4318+
*/
4319+
@java.io.Serial
4320+
private void readObjectNoData()
4321+
throws ObjectStreamException {
4322+
throw new InvalidObjectException("Deserialized BigDecimal objects need data");
42904323
}
42914324

42924325
/**

src/java.base/share/classes/java/math/BigInteger.java

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@
3030
package java.math;
3131

3232
import java.io.IOException;
33+
import java.io.InvalidObjectException;
3334
import java.io.ObjectInputStream;
3435
import java.io.ObjectOutputStream;
3536
import java.io.ObjectStreamField;
37+
import java.io.ObjectStreamException;
3638
import java.util.Arrays;
3739
import java.util.Objects;
3840
import java.util.Random;
@@ -4706,17 +4708,21 @@ private void readObject(java.io.ObjectInputStream s)
47064708
// prepare to read the alternate persistent fields
47074709
ObjectInputStream.GetField fields = s.readFields();
47084710

4709-
// Read the alternate persistent fields that we care about
4710-
int sign = fields.get("signum", -2);
4711-
byte[] magnitude = (byte[])fields.get("magnitude", null);
4711+
// Read and validate the alternate persistent fields that we
4712+
// care about, signum and magnitude
47124713

4713-
// Validate signum
4714+
// Read and validate signum
4715+
int sign = fields.get("signum", -2);
47144716
if (sign < -1 || sign > 1) {
47154717
String message = "BigInteger: Invalid signum value";
47164718
if (fields.defaulted("signum"))
47174719
message = "BigInteger: Signum not present in stream";
47184720
throw new java.io.StreamCorruptedException(message);
47194721
}
4722+
4723+
// Read and validate magnitude
4724+
byte[] magnitude = (byte[])fields.get("magnitude", null);
4725+
magnitude = magnitude.clone(); // defensive copy
47204726
int[] mag = stripLeadingZeroBytes(magnitude, 0, magnitude.length);
47214727
if ((mag.length == 0) != (sign == 0)) {
47224728
String message = "BigInteger: signum-magnitude mismatch";
@@ -4725,18 +4731,24 @@ private void readObject(java.io.ObjectInputStream s)
47254731
throw new java.io.StreamCorruptedException(message);
47264732
}
47274733

4734+
// Equivalent to checkRange() on mag local without assigning
4735+
// this.mag field
4736+
if (mag.length > MAX_MAG_LENGTH ||
4737+
(mag.length == MAX_MAG_LENGTH && mag[0] < 0)) {
4738+
throw new java.io.StreamCorruptedException("BigInteger: Out of the supported range");
4739+
}
4740+
47284741
// Commit final fields via Unsafe
4729-
UnsafeHolder.putSign(this, sign);
4742+
UnsafeHolder.putSignAndMag(this, sign, mag);
4743+
}
47304744

4731-
// Calculate mag field from magnitude and discard magnitude
4732-
UnsafeHolder.putMag(this, mag);
4733-
if (mag.length >= MAX_MAG_LENGTH) {
4734-
try {
4735-
checkRange();
4736-
} catch (ArithmeticException e) {
4737-
throw new java.io.StreamCorruptedException("BigInteger: Out of the supported range");
4738-
}
4739-
}
4745+
/**
4746+
* Serialization without data not supported for this class.
4747+
*/
4748+
@java.io.Serial
4749+
private void readObjectNoData()
4750+
throws ObjectStreamException {
4751+
throw new InvalidObjectException("Deserialized BigInteger objects need data");
47404752
}
47414753

47424754
// Support for resetting final fields while deserializing
@@ -4748,11 +4760,8 @@ private static class UnsafeHolder {
47484760
private static final long magOffset
47494761
= unsafe.objectFieldOffset(BigInteger.class, "mag");
47504762

4751-
static void putSign(BigInteger bi, int sign) {
4763+
static void putSignAndMag(BigInteger bi, int sign, int[] magnitude) {
47524764
unsafe.putInt(bi, signumOffset, sign);
4753-
}
4754-
4755-
static void putMag(BigInteger bi, int[] magnitude) {
47564765
unsafe.putReference(bi, magOffset, magnitude);
47574766
}
47584767
}

0 commit comments

Comments
 (0)