diff options
author | chegar <none@none> | 2013-11-08 15:15:48 +0000 |
---|---|---|
committer | chegar <none@none> | 2013-11-08 15:15:48 +0000 |
commit | 5f195188387a75720f6c59be7746876f328714a3 (patch) | |
tree | 6a2092bec8998d2750d0858d7cfe1e9f4cfb66b9 /src | |
parent | 5cdc8d11283111ab845d8cb447927593bd53fa14 (diff) |
8019834: InetAddress.getByName hangs for bad IPv6 literals
Reviewed-by: alanb
Diffstat (limited to 'src')
-rw-r--r-- | src/share/classes/java/net/InetAddress.java | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/share/classes/java/net/InetAddress.java b/src/share/classes/java/net/InetAddress.java index 3bb7249d7..05e230e7d 100644 --- a/src/share/classes/java/net/InetAddress.java +++ b/src/share/classes/java/net/InetAddress.java @@ -1135,7 +1135,7 @@ class InetAddress implements java.io.Serializable { // see if it is IPv4 address addr = IPAddressUtil.textToNumericFormatV4(host); if (addr == null) { - // see if it is IPv6 address + // This is supposed to be an IPv6 literal // Check if a numeric or string zone id is present int pos; if ((pos=host.indexOf ("%")) != -1) { @@ -1144,7 +1144,9 @@ class InetAddress implements java.io.Serializable { ifname = host.substring (pos+1); } } - addr = IPAddressUtil.textToNumericFormatV6(host); + if ((addr = IPAddressUtil.textToNumericFormatV6(host)) == null) { + throw new UnknownHostException(host + ": invalid IPv6 address"); + } } else if (ipv6Expected) { // Means an IPv4 litteral between brackets! throw new UnknownHostException("["+host+"]"); @@ -1162,10 +1164,10 @@ class InetAddress implements java.io.Serializable { } return ret; } - } else if (ipv6Expected) { - // We were expecting an IPv6 Litteral, but got something else - throw new UnknownHostException("["+host+"]"); - } + } else if (ipv6Expected) { + // We were expecting an IPv6 Litteral, but got something else + throw new UnknownHostException("["+host+"]"); + } return getAllByName0(host, reqAddr, true); } |