summaryrefslogtreecommitdiff
path: root/java/net
diff options
context:
space:
mode:
authorGary Benson <gbenson@redhat.com>2006-09-08 12:58:13 +0000
committerGary Benson <gbenson@redhat.com>2006-09-08 12:58:13 +0000
commit48c8f452dc0d10c1fd76e7bba737e81cbd0615b3 (patch)
tree776b108d76ebf3295ee24f83e79f7e6c154602b1 /java/net
parent4097782685ff67cdaf9f6b60a5ca99cb589f4141 (diff)
downloadclasspath-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).
Diffstat (limited to 'java/net')
-rw-r--r--java/net/InetAddress.java36
1 files changed, 14 insertions, 22 deletions
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;
}
/**