summaryrefslogtreecommitdiff
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
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).
-rw-r--r--ChangeLog7
-rw-r--r--java/net/InetAddress.java36
2 files changed, 21 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 2befd86cd..fb688d60f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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;
}
/**