mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
Merge
Reviewed-by: alanb, dfuchs
This commit is contained in:
commit
cf5bb12731
79 changed files with 3346 additions and 911 deletions
|
@ -253,6 +253,15 @@ to determine the proxy that should be used for connecting to a given URI.</P>
|
|||
</OL>
|
||||
<P>The channel binding tokens generated are of the type "tls-server-end-point" as defined in
|
||||
RFC 5929.</P>
|
||||
|
||||
<LI><P><B>{@systemProperty jdk.http.maxHeaderSize}</B> (default: 393216 or 384kB)<BR>
|
||||
This is the maximum header field section size that a client is prepared to accept.
|
||||
This is computed as the sum of the size of the uncompressed header name, plus
|
||||
the size of the uncompressed header value, plus an overhead of 32 bytes for
|
||||
each field section line. If a peer sends a field section that exceeds this
|
||||
size a {@link java.net.ProtocolException ProtocolException} will be raised.
|
||||
This applies to all versions of the HTTP protocol. A value of zero or a negative
|
||||
value means no limit. If left unspecified, the default value is 393216 bytes.
|
||||
</UL>
|
||||
<P>All these properties are checked only once at startup.</P>
|
||||
<a id="AddressCache"></a>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2024, 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
|
||||
|
@ -407,6 +407,11 @@ implements Serializable
|
|||
@SuppressWarnings("unchecked")
|
||||
Hashtable<Class<?>, PermissionCollection> perms =
|
||||
(Hashtable<Class<?>, PermissionCollection>)gfields.get("perms", null);
|
||||
|
||||
if (perms == null) {
|
||||
throw new InvalidObjectException("perms can't be null");
|
||||
}
|
||||
|
||||
permsMap = new ConcurrentHashMap<>(perms.size()*2);
|
||||
permsMap.putAll(perms);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2024, 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
|
||||
|
@ -152,20 +152,20 @@ public final class SignedObject implements Serializable {
|
|||
*/
|
||||
public SignedObject(Serializable object, PrivateKey signingKey,
|
||||
Signature signingEngine)
|
||||
throws IOException, InvalidKeyException, SignatureException {
|
||||
// creating a stream pipe-line, from a to b
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
ObjectOutput a = new ObjectOutputStream(b);
|
||||
throws IOException, InvalidKeyException, SignatureException {
|
||||
// creating a stream pipe-line, from a to b
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
ObjectOutput a = new ObjectOutputStream(b);
|
||||
|
||||
// write and flush the object content to byte array
|
||||
a.writeObject(object);
|
||||
a.flush();
|
||||
a.close();
|
||||
this.content = b.toByteArray();
|
||||
b.close();
|
||||
// write and flush the object content to byte array
|
||||
a.writeObject(object);
|
||||
a.flush();
|
||||
a.close();
|
||||
this.content = b.toByteArray();
|
||||
b.close();
|
||||
|
||||
// now sign the encapsulated object
|
||||
this.sign(signingKey, signingEngine);
|
||||
// now sign the encapsulated object
|
||||
this.sign(signingKey, signingEngine);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -245,12 +245,12 @@ public final class SignedObject implements Serializable {
|
|||
* @throws SignatureException if signing fails.
|
||||
*/
|
||||
private void sign(PrivateKey signingKey, Signature signingEngine)
|
||||
throws InvalidKeyException, SignatureException {
|
||||
// initialize the signing engine
|
||||
signingEngine.initSign(signingKey);
|
||||
signingEngine.update(this.content.clone());
|
||||
this.signature = signingEngine.sign().clone();
|
||||
this.thealgorithm = signingEngine.getAlgorithm();
|
||||
throws InvalidKeyException, SignatureException {
|
||||
// initialize the signing engine
|
||||
signingEngine.initSign(signingKey);
|
||||
signingEngine.update(this.content.clone());
|
||||
this.signature = signingEngine.sign();
|
||||
this.thealgorithm = signingEngine.getAlgorithm();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -263,10 +263,16 @@ public final class SignedObject implements Serializable {
|
|||
*/
|
||||
@Serial
|
||||
private void readObject(ObjectInputStream s)
|
||||
throws IOException, ClassNotFoundException {
|
||||
ObjectInputStream.GetField fields = s.readFields();
|
||||
content = ((byte[])fields.get("content", null)).clone();
|
||||
signature = ((byte[])fields.get("signature", null)).clone();
|
||||
thealgorithm = (String)fields.get("thealgorithm", null);
|
||||
throws IOException, ClassNotFoundException {
|
||||
ObjectInputStream.GetField fields = s.readFields();
|
||||
byte[] c = (byte[]) fields.get("content", null);
|
||||
byte[] sig = (byte[]) fields.get("signature", null);
|
||||
String a = (String) fields.get("thealgorithm", null);
|
||||
if (c == null || sig == null || a == null) {
|
||||
throw new InvalidObjectException("One or more null fields");
|
||||
}
|
||||
content = c.clone();
|
||||
signature = sig.clone();
|
||||
thealgorithm = a;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2024, 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
|
||||
|
@ -27,6 +27,7 @@ package java.security;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.Serializable;
|
||||
import java.security.cert.CertPath;
|
||||
import java.security.cert.Certificate;
|
||||
|
@ -78,7 +79,7 @@ public final class Timestamp implements Serializable {
|
|||
* {@code null}.
|
||||
*/
|
||||
public Timestamp(Date timestamp, CertPath signerCertPath) {
|
||||
if (timestamp == null || signerCertPath == null) {
|
||||
if (isNull(timestamp, signerCertPath)) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
this.timestamp = new Date(timestamp.getTime()); // clone
|
||||
|
@ -166,9 +167,16 @@ public final class Timestamp implements Serializable {
|
|||
*/
|
||||
@java.io.Serial
|
||||
private void readObject(ObjectInputStream ois)
|
||||
throws IOException, ClassNotFoundException {
|
||||
throws IOException, ClassNotFoundException {
|
||||
ois.defaultReadObject();
|
||||
if (isNull(timestamp, signerCertPath)) {
|
||||
throw new InvalidObjectException("Invalid null field(s)");
|
||||
}
|
||||
myhash = -1;
|
||||
timestamp = new Date(timestamp.getTime());
|
||||
}
|
||||
|
||||
private static boolean isNull(Date d, CertPath c) {
|
||||
return (d == null || c == null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2024, 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
|
||||
|
@ -29,6 +29,7 @@ import java.io.IOException;
|
|||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectStreamField;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
@ -196,23 +197,32 @@ implements java.io.Serializable
|
|||
ObjectInputStream.GetField gfields = in.readFields();
|
||||
|
||||
// Get permissions
|
||||
@SuppressWarnings("unchecked")
|
||||
// writeObject writes a Hashtable<String, Vector<UnresolvedPermission>>
|
||||
// for the permissions key, so this cast is safe, unless the data is corrupt.
|
||||
Hashtable<String, Vector<UnresolvedPermission>> permissions =
|
||||
(Hashtable<String, Vector<UnresolvedPermission>>)
|
||||
gfields.get("permissions", null);
|
||||
perms = new ConcurrentHashMap<>(permissions.size()*2);
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
Hashtable<String, Vector<UnresolvedPermission>> permissions =
|
||||
(Hashtable<String, Vector<UnresolvedPermission>>)
|
||||
gfields.get("permissions", null);
|
||||
|
||||
// Convert each entry (Vector) into a List
|
||||
Set<Map.Entry<String, Vector<UnresolvedPermission>>> set = permissions.entrySet();
|
||||
for (Map.Entry<String, Vector<UnresolvedPermission>> e : set) {
|
||||
// Convert Vector into ArrayList
|
||||
Vector<UnresolvedPermission> vec = e.getValue();
|
||||
List<UnresolvedPermission> list = new CopyOnWriteArrayList<>(vec);
|
||||
if (permissions == null) {
|
||||
throw new InvalidObjectException("Invalid null permissions");
|
||||
}
|
||||
|
||||
// Add to Hashtable being serialized
|
||||
perms.put(e.getKey(), list);
|
||||
perms = new ConcurrentHashMap<>(permissions.size()*2);
|
||||
|
||||
// Convert each entry (Vector) into a List
|
||||
Set<Map.Entry<String, Vector<UnresolvedPermission>>> set = permissions.entrySet();
|
||||
for (Map.Entry<String, Vector<UnresolvedPermission>> e : set) {
|
||||
// Convert Vector into ArrayList
|
||||
Vector<UnresolvedPermission> vec = e.getValue();
|
||||
List<UnresolvedPermission> list = new CopyOnWriteArrayList<>(vec);
|
||||
|
||||
// Add to Hashtable being serialized
|
||||
perms.put(e.getKey(), list);
|
||||
}
|
||||
} catch (ClassCastException cce) {
|
||||
throw new InvalidObjectException("Invalid type for permissions");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2024, 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
|
||||
|
@ -28,6 +28,7 @@ package java.security.cert;
|
|||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
@ -70,6 +71,13 @@ public class CertificateRevokedException extends CertificateException {
|
|||
|
||||
private transient Map<String, Extension> extensions;
|
||||
|
||||
private static boolean isNull(Date revocationDate,
|
||||
CRLReason reason, X500Principal authority,
|
||||
Map<String, Extension> extensions) {
|
||||
return (revocationDate == null || reason == null || authority == null
|
||||
|| extensions == null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@code CertificateRevokedException} with
|
||||
* the specified revocation date, reason code, authority name, and map
|
||||
|
@ -92,8 +100,7 @@ public class CertificateRevokedException extends CertificateException {
|
|||
*/
|
||||
public CertificateRevokedException(Date revocationDate, CRLReason reason,
|
||||
X500Principal authority, Map<String, Extension> extensions) {
|
||||
if (revocationDate == null || reason == null || authority == null ||
|
||||
extensions == null) {
|
||||
if (isNull(revocationDate, reason, authority, extensions)) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
this.revocationDate = new Date(revocationDate.getTime());
|
||||
|
@ -234,9 +241,6 @@ public class CertificateRevokedException extends CertificateException {
|
|||
// (revocationDate, reason, authority)
|
||||
ois.defaultReadObject();
|
||||
|
||||
// Defensively copy the revocation date
|
||||
revocationDate = new Date(revocationDate.getTime());
|
||||
|
||||
// Read in the size (number of mappings) of the extensions map
|
||||
// and create the extensions map
|
||||
int size = ois.readInt();
|
||||
|
@ -247,6 +251,13 @@ public class CertificateRevokedException extends CertificateException {
|
|||
} else {
|
||||
extensions = HashMap.newHashMap(Math.min(size, 20));
|
||||
}
|
||||
// make sure all fields are set before checking
|
||||
if (isNull(revocationDate, reason, authority, extensions)) {
|
||||
throw new InvalidObjectException("Invalid null field(s)");
|
||||
}
|
||||
|
||||
// Defensively copy the revocation date
|
||||
revocationDate = new Date(revocationDate.getTime());
|
||||
|
||||
// Read in the extensions and put the mappings in the extensions map
|
||||
for (int i = 0; i < size; i++) {
|
||||
|
|
|
@ -41,6 +41,7 @@ package java.text;
|
|||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -1181,6 +1182,8 @@ public class MessageFormat extends Format {
|
|||
maximumArgumentNumber = argumentNumbers[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Constructors/applyPattern ensure that resultArray.length < MAX_ARGUMENT_INDEX
|
||||
Object[] resultArray = new Object[maximumArgumentNumber + 1];
|
||||
|
||||
int patternOffset = 0;
|
||||
|
@ -1459,6 +1462,9 @@ public class MessageFormat extends Format {
|
|||
* @serial
|
||||
*/
|
||||
private int[] argumentNumbers = new int[INITIAL_FORMATS];
|
||||
// Implementation limit for ArgumentIndex pattern element. Valid indices must
|
||||
// be less than this value
|
||||
private static final int MAX_ARGUMENT_INDEX = 10000;
|
||||
|
||||
/**
|
||||
* One less than the number of entries in {@code offsets}. Can also be thought of
|
||||
|
@ -1639,6 +1645,11 @@ public class MessageFormat extends Format {
|
|||
+ argumentNumber);
|
||||
}
|
||||
|
||||
if (argumentNumber >= MAX_ARGUMENT_INDEX) {
|
||||
throw new IllegalArgumentException(
|
||||
argumentNumber + " exceeds the ArgumentIndex implementation limit");
|
||||
}
|
||||
|
||||
// resize format information arrays if necessary
|
||||
if (offsetNumber >= formats.length) {
|
||||
int newLength = formats.length * 2;
|
||||
|
@ -2006,24 +2017,53 @@ public class MessageFormat extends Format {
|
|||
*/
|
||||
@java.io.Serial
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
boolean isValid = maxOffset >= -1
|
||||
&& formats.length > maxOffset
|
||||
&& offsets.length > maxOffset
|
||||
&& argumentNumbers.length > maxOffset;
|
||||
ObjectInputStream.GetField fields = in.readFields();
|
||||
if (fields.defaulted("argumentNumbers") || fields.defaulted("offsets")
|
||||
|| fields.defaulted("formats") || fields.defaulted("locale")
|
||||
|| fields.defaulted("pattern") || fields.defaulted("maxOffset")){
|
||||
throw new InvalidObjectException("Stream has missing data");
|
||||
}
|
||||
|
||||
locale = (Locale) fields.get("locale", null);
|
||||
String patt = (String) fields.get("pattern", null);
|
||||
int maxOff = fields.get("maxOffset", -2);
|
||||
int[] argNums = ((int[]) fields.get("argumentNumbers", null)).clone();
|
||||
int[] offs = ((int[]) fields.get("offsets", null)).clone();
|
||||
Format[] fmts = ((Format[]) fields.get("formats", null)).clone();
|
||||
|
||||
// Check arrays/maxOffset have correct value/length
|
||||
boolean isValid = maxOff >= -1 && argNums.length > maxOff
|
||||
&& offs.length > maxOff && fmts.length > maxOff;
|
||||
|
||||
// Check the correctness of arguments and offsets
|
||||
if (isValid) {
|
||||
int lastOffset = pattern.length() + 1;
|
||||
for (int i = maxOffset; i >= 0; --i) {
|
||||
if ((offsets[i] < 0) || (offsets[i] > lastOffset)) {
|
||||
int lastOffset = patt.length() + 1;
|
||||
for (int i = maxOff; i >= 0; --i) {
|
||||
if (argNums[i] < 0 || argNums[i] >= MAX_ARGUMENT_INDEX
|
||||
|| offs[i] < 0 || offs[i] > lastOffset) {
|
||||
isValid = false;
|
||||
break;
|
||||
} else {
|
||||
lastOffset = offsets[i];
|
||||
lastOffset = offs[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
throw new InvalidObjectException("Could not reconstruct MessageFormat from corrupt stream.");
|
||||
throw new InvalidObjectException("Stream has invalid data");
|
||||
}
|
||||
maxOffset = maxOff;
|
||||
pattern = patt;
|
||||
offsets = offs;
|
||||
formats = fmts;
|
||||
argumentNumbers = argNums;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialization without data not supported for this class.
|
||||
*/
|
||||
@java.io.Serial
|
||||
private void readObjectNoData() throws ObjectStreamException {
|
||||
throw new InvalidObjectException("Deserialized MessageFormat objects need data");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue