mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8296676: Improve String platform support
Reviewed-by: aefimov, dfuchs
This commit is contained in:
parent
5ec0120152
commit
ec119716e5
2 changed files with 35 additions and 2 deletions
|
@ -1062,6 +1062,7 @@ public sealed class InetAddress implements Serializable permits Inet4Address, In
|
|||
throws UnknownHostException {
|
||||
Objects.requireNonNull(host);
|
||||
Objects.requireNonNull(policy);
|
||||
validate(host);
|
||||
InetAddress[] addrs;
|
||||
long comp = Blocker.begin();
|
||||
try {
|
||||
|
@ -1475,6 +1476,7 @@ public sealed class InetAddress implements Serializable permits Inet4Address, In
|
|||
return ret;
|
||||
}
|
||||
|
||||
validate(host);
|
||||
boolean ipv6Expected = false;
|
||||
if (host.charAt(0) == '[') {
|
||||
// This is supposed to be an IPv6 literal
|
||||
|
@ -1873,4 +1875,10 @@ public sealed class InetAddress implements Serializable permits Inet4Address, In
|
|||
pf.put("family", holder().getFamily());
|
||||
s.writeFields();
|
||||
}
|
||||
|
||||
private static void validate(String host) throws UnknownHostException {
|
||||
if (host.indexOf(0) != -1) {
|
||||
throw new UnknownHostException("NUL character not allowed in hostname");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue