mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
Merge
This commit is contained in:
commit
fc9f8baf56
27 changed files with 446 additions and 231 deletions
|
@ -1508,6 +1508,10 @@ public sealed class InetAddress implements Serializable permits Inet4Address, In
|
|||
InetAddress[] ret = new InetAddress[1];
|
||||
if(addr != null) {
|
||||
if (addr.length == Inet4Address.INADDRSZ) {
|
||||
if (numericZone != -1 || ifname != null) {
|
||||
// IPv4-mapped address must not contain zone-id
|
||||
throw new UnknownHostException(host + ": invalid IPv4-mapped address");
|
||||
}
|
||||
ret[0] = new Inet4Address(null, addr);
|
||||
} else {
|
||||
if (ifname != null) {
|
||||
|
@ -1552,22 +1556,23 @@ public sealed class InetAddress implements Serializable permits Inet4Address, In
|
|||
int percent = s.indexOf ('%');
|
||||
int slen = s.length();
|
||||
int digit, zone=0;
|
||||
int multmax = Integer.MAX_VALUE / 10; // for int overflow detection
|
||||
if (percent == -1) {
|
||||
return -1;
|
||||
}
|
||||
for (int i=percent+1; i<slen; i++) {
|
||||
char c = s.charAt(i);
|
||||
if (c == ']') {
|
||||
if (i == percent+1) {
|
||||
/* empty per-cent field */
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
if ((digit = IPAddressUtil.parseAsciiDigit(c, 10)) < 0) {
|
||||
return -1;
|
||||
}
|
||||
if ((digit = Character.digit (c, 10)) < 0) {
|
||||
if (zone > multmax) {
|
||||
return -1;
|
||||
}
|
||||
zone = (zone * 10) + digit;
|
||||
if (zone < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
return zone;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue