Skip to content

Commit 054bee5

Browse files
authored
Merge pull request #204 from ibmruntimes/openj9-staging
Merge jdk-17.0.7+7 and OpenJ9 changes to 0.38
2 parents facc368 + 1a56468 commit 054bee5

File tree

33 files changed

+349
-181
lines changed

33 files changed

+349
-181
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.7+6
1+
OPENJDK_TAG := jdk-17.0.7+7

make/conf/version-numbers.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2011, 2023, 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
@@ -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=

src/java.base/share/classes/java/lang/ProcessBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,8 +1100,8 @@ private Process start(Redirect[] redirects) throws IOException {
11001100

11011101
String dir = directory == null ? null : directory.toString();
11021102

1103-
for (int i = 1; i < cmdarray.length; i++) {
1104-
if (cmdarray[i].indexOf('\u0000') >= 0) {
1103+
for (String s : cmdarray) {
1104+
if (s.indexOf('\u0000') >= 0) {
11051105
throw new IOException("invalid null character in command");
11061106
}
11071107
}

src/java.base/share/classes/java/net/InetAddress.java

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2023, 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
@@ -930,6 +930,7 @@ private static final class PlatformNameService implements NameService {
930930
public InetAddress[] lookupAllHostAddr(String host)
931931
throws UnknownHostException
932932
{
933+
validate(host);
933934
return impl.lookupAllHostAddr(host);
934935
}
935936

@@ -1314,51 +1315,53 @@ private static InetAddress[] getAllByName(String host, InetAddress reqAddr)
13141315
return ret;
13151316
}
13161317

1318+
validate(host);
13171319
boolean ipv6Expected = false;
13181320
if (host.charAt(0) == '[') {
13191321
// This is supposed to be an IPv6 literal
13201322
if (host.length() > 2 && host.charAt(host.length()-1) == ']') {
13211323
host = host.substring(1, host.length() -1);
13221324
ipv6Expected = true;
13231325
} else {
1324-
// This was supposed to be a IPv6 address, but it's not!
1325-
throw new UnknownHostException(host + ": invalid IPv6 address");
1326+
// This was supposed to be a IPv6 literal, but it's not
1327+
throw invalidIPv6LiteralException(host, false);
13261328
}
13271329
}
13281330

1329-
// if host is an IP address, we won't do further lookup
1331+
// Check and try to parse host string as an IP address literal
13301332
if (IPAddressUtil.digit(host.charAt(0), 16) != -1
13311333
|| (host.charAt(0) == ':')) {
1332-
byte[] addr;
1334+
byte[] addr = null;
13331335
int numericZone = -1;
13341336
String ifname = null;
1335-
// see if it is IPv4 address
1336-
try {
1337-
addr = IPAddressUtil.validateNumericFormatV4(host);
1338-
} catch (IllegalArgumentException iae) {
1339-
var uhe = new UnknownHostException(host);
1340-
uhe.initCause(iae);
1341-
throw uhe;
1337+
1338+
if (!ipv6Expected) {
1339+
// check if it is IPv4 address only if host is not wrapped in '[]'
1340+
try {
1341+
addr = IPAddressUtil.validateNumericFormatV4(host);
1342+
} catch (IllegalArgumentException iae) {
1343+
var uhe = new UnknownHostException(host);
1344+
uhe.initCause(iae);
1345+
throw uhe;
1346+
}
13421347
}
13431348
if (addr == null) {
1344-
// This is supposed to be an IPv6 literal
1345-
// Check if a numeric or string zone id is present
1349+
// Try to parse host string as an IPv6 literal
1350+
// Check if a numeric or string zone id is present first
13461351
int pos;
1347-
if ((pos=host.indexOf ('%')) != -1) {
1348-
numericZone = checkNumericZone (host);
1352+
if ((pos = host.indexOf('%')) != -1) {
1353+
numericZone = checkNumericZone(host);
13491354
if (numericZone == -1) { /* remainder of string must be an ifname */
1350-
ifname = host.substring (pos+1);
1355+
ifname = host.substring(pos + 1);
13511356
}
13521357
}
1353-
if ((addr = IPAddressUtil.textToNumericFormatV6(host)) == null && host.contains(":")) {
1354-
throw new UnknownHostException(host + ": invalid IPv6 address");
1358+
if ((addr = IPAddressUtil.textToNumericFormatV6(host)) == null &&
1359+
(host.contains(":") || ipv6Expected)) {
1360+
throw invalidIPv6LiteralException(host, ipv6Expected);
13551361
}
1356-
} else if (ipv6Expected) {
1357-
// Means an IPv4 literal between brackets!
1358-
throw new UnknownHostException("["+host+"]");
13591362
}
1360-
InetAddress[] ret = new InetAddress[1];
13611363
if(addr != null) {
1364+
InetAddress[] ret = new InetAddress[1];
13621365
if (addr.length == Inet4Address.INADDRSZ) {
13631366
if (numericZone != -1 || ifname != null) {
13641367
// IPv4-mapped address must not contain zone-id
@@ -1375,12 +1378,18 @@ private static InetAddress[] getAllByName(String host, InetAddress reqAddr)
13751378
return ret;
13761379
}
13771380
} else if (ipv6Expected) {
1378-
// We were expecting an IPv6 Literal, but got something else
1379-
throw new UnknownHostException("["+host+"]");
1381+
// We were expecting an IPv6 Literal since host string starts
1382+
// and ends with square brackets, but we got something else.
1383+
throw invalidIPv6LiteralException(host, true);
13801384
}
13811385
return getAllByName0(host, reqAddr, true, true);
13821386
}
13831387

1388+
private static UnknownHostException invalidIPv6LiteralException(String host, boolean wrapInBrackets) {
1389+
String hostString = wrapInBrackets ? "[" + host + "]" : host;
1390+
return new UnknownHostException(hostString + ": invalid IPv6 address literal");
1391+
}
1392+
13841393
/**
13851394
* Returns the loopback address.
13861395
* <p>
@@ -1802,6 +1811,12 @@ private void writeObject (ObjectOutputStream s) throws
18021811
pf.put("family", holder().getFamily());
18031812
s.writeFields();
18041813
}
1814+
1815+
private static void validate(String host) throws UnknownHostException {
1816+
if (host.indexOf(0) != -1) {
1817+
throw new UnknownHostException("NUL character not allowed in hostname");
1818+
}
1819+
}
18051820
}
18061821

18071822
/*

src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2372,7 +2372,8 @@ private void setPreemptiveProxyAuthentication(MessageHeader requests) throws IOE
23722372
* the connection.
23732373
*/
23742374
@SuppressWarnings({"removal","fallthrough"})
2375-
private AuthenticationInfo getHttpProxyAuthentication(AuthenticationHeader authhdr) {
2375+
private AuthenticationInfo getHttpProxyAuthentication(AuthenticationHeader authhdr)
2376+
throws IOException {
23762377

23772378
assert isLockHeldByCurrentThread();
23782379

@@ -2473,6 +2474,7 @@ public InetAddress run()
24732474
authenticator,
24742475
host, null, port, url.getProtocol(),
24752476
"", scheme, url, RequestorType.PROXY);
2477+
validateNTLMCredentials(a);
24762478
}
24772479
/* If we are not trying transparent authentication then
24782480
* we need to have a PasswordAuthentication instance. For
@@ -2540,7 +2542,8 @@ public InetAddress run()
25402542
* preferred.
25412543
*/
25422544
@SuppressWarnings("fallthrough")
2543-
private AuthenticationInfo getServerAuthentication(AuthenticationHeader authhdr) {
2545+
private AuthenticationInfo getServerAuthentication(AuthenticationHeader authhdr)
2546+
throws IOException {
25442547

25452548
// Only called from getInputStream0
25462549
assert isLockHeldByCurrentThread();
@@ -2652,6 +2655,7 @@ private AuthenticationInfo getServerAuthentication(AuthenticationHeader authhdr)
26522655
authenticator,
26532656
url.getHost(), addr, port, url.getProtocol(),
26542657
"", scheme, url, RequestorType.SERVER);
2658+
validateNTLMCredentials(a);
26552659
}
26562660

26572661
/* If we are not trying transparent authentication then
@@ -4003,6 +4007,27 @@ public void close() throws IOException {
40034007
}
40044008
}
40054009
}
4010+
4011+
// ensure there are no null characters in username or password
4012+
private static void validateNTLMCredentials(PasswordAuthentication pw)
4013+
throws IOException {
4014+
4015+
if (pw == null) {
4016+
return;
4017+
}
4018+
char[] password = pw.getPassword();
4019+
if (password != null) {
4020+
for (int i=0; i<password.length; i++) {
4021+
if (password[i] == 0) {
4022+
throw new IOException("NUL character not allowed in NTLM password");
4023+
}
4024+
}
4025+
}
4026+
String username = pw.getUserName();
4027+
if (username != null && username.indexOf(0) != -1) {
4028+
throw new IOException("NUL character not allowed in NTLM username or domain");
4029+
}
4030+
}
40064031
}
40074032

40084033
/** An input stream that just returns EOF. This is for

src/java.base/share/classes/sun/security/provider/certpath/AdjacencyList.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2023, 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
@@ -87,7 +87,7 @@ public class AdjacencyList {
8787
// the actual set of steps the AdjacencyList represents
8888
private ArrayList<BuildStep> mStepList;
8989

90-
// the original list, just for the toString method
90+
// the original list
9191
private List<List<Vertex>> mOrigList;
9292

9393
/**
@@ -114,6 +114,13 @@ public Iterator<BuildStep> iterator() {
114114
return Collections.unmodifiableList(mStepList).iterator();
115115
}
116116

117+
/**
118+
* Returns the number of attempted paths (useful for debugging).
119+
*/
120+
public int numAttemptedPaths() {
121+
return mOrigList.size();
122+
}
123+
117124
/**
118125
* Recursive, private method which actually builds the step list from
119126
* the given adjacency list. <code>Follow</code> is the parent BuildStep

src/java.base/share/classes/sun/security/provider/certpath/Builder.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2023, 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
@@ -412,8 +412,7 @@ Set<String> getMatchingPolicies() {
412412

413413
/**
414414
* Search the specified CertStores and add all certificates matching
415-
* selector to resultCerts. Self-signed certs are not useful here
416-
* and therefore ignored.
415+
* selector to resultCerts.
417416
*
418417
* If the targetCert criterion of the selector is set, only that cert
419418
* is examined and the CertStores are not searched.
@@ -432,8 +431,7 @@ boolean addMatchingCerts(X509CertSelector selector,
432431
X509Certificate targetCert = selector.getCertificate();
433432
if (targetCert != null) {
434433
// no need to search CertStores
435-
if (selector.match(targetCert) && !X509CertImpl.isSelfSigned
436-
(targetCert, buildParams.sigProvider())) {
434+
if (selector.match(targetCert)) {
437435
if (debug != null) {
438436
debug.println("Builder.addMatchingCerts: " +
439437
"adding target cert" +
@@ -452,11 +450,8 @@ boolean addMatchingCerts(X509CertSelector selector,
452450
Collection<? extends Certificate> certs =
453451
store.getCertificates(selector);
454452
for (Certificate cert : certs) {
455-
if (!X509CertImpl.isSelfSigned
456-
((X509Certificate)cert, buildParams.sigProvider())) {
457-
if (resultCerts.add((X509Certificate)cert)) {
458-
add = true;
459-
}
453+
if (resultCerts.add((X509Certificate)cert)) {
454+
add = true;
460455
}
461456
}
462457
if (!checkAll && add) {

0 commit comments

Comments
 (0)