diff options
author | Gary Benson <gbenson@redhat.com> | 2006-09-08 12:58:13 +0000 |
---|---|---|
committer | Gary Benson <gbenson@redhat.com> | 2006-09-08 12:58:13 +0000 |
commit | 48c8f452dc0d10c1fd76e7bba737e81cbd0615b3 (patch) | |
tree | 776b108d76ebf3295ee24f83e79f7e6c154602b1 | |
parent | 4097782685ff67cdaf9f6b60a5ca99cb589f4141 (diff) | |
download | classpath-48c8f452dc0d10c1fd76e7bba737e81cbd0615b3.tar.gz |
2006-09-08 Gary Benson <gbenson@redhat.com>
* java/net/InetAddress.java
(getHostName): Move lookup into getCanonicalHostName.
(getCanonicalHostName): Move lookup from getHostName,
Perform security check on canonical name (ie after lookup).
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | java/net/InetAddress.java | 36 |
2 files changed, 21 insertions, 22 deletions
@@ -1,5 +1,12 @@ 2006-09-08 Gary Benson <gbenson@redhat.com> + * java/net/InetAddress.java + (getHostName): Move lookup into getCanonicalHostName. + (getCanonicalHostName): Move lookup from getHostName, + Perform security check on canonical name (ie after lookup). + +2006-09-08 Gary Benson <gbenson@redhat.com> + * java/net/Inet4Address.java (isMulticastAddress, isLoopbackAddress, isAnyLocalAddress, isLinkLocalAddress, isSiteLocalAddress, isMCGlobal, isMCNodeLocal, isMCLinkLocal, diff --git a/java/net/InetAddress.java b/java/net/InetAddress.java index 23a2afc2d..9d515190a 100644 --- a/java/net/InetAddress.java +++ b/java/net/InetAddress.java @@ -307,17 +307,8 @@ public class InetAddress implements Serializable */ public String getHostName() { - if (hostName != null) - return hostName; - - try - { - hostName = VMInetAddress.getHostByAddr(addr); - } - catch (UnknownHostException e) - { - hostName = getHostAddress(); - } + if (hostName == null) + hostName = getCanonicalHostName(); return hostName; } @@ -329,12 +320,22 @@ public class InetAddress implements Serializable */ public String getCanonicalHostName() { + String hostname; + try + { + hostname = VMInetAddress.getHostByAddr(addr); + } + catch (UnknownHostException e) + { + return getHostAddress(); + } + SecurityManager sm = System.getSecurityManager(); if (sm != null) { try { - sm.checkConnect(hostName, -1); + sm.checkConnect(hostname, -1); } catch (SecurityException e) { @@ -342,16 +343,7 @@ public class InetAddress implements Serializable } } - // Try to find the FDQN now - InetAddress address; - byte[] ipaddr = getAddress(); - - if (ipaddr.length == 16) - address = new Inet6Address(getAddress(), null); - else - address = new Inet4Address(getAddress(), null); - - return address.getHostName(); + return hostname; } /** |