diff options
author | Gary Benson <gbenson@redhat.com> | 2006-09-01 10:06:13 +0000 |
---|---|---|
committer | Gary Benson <gary@gcc.gnu.org> | 2006-09-01 10:06:13 +0000 |
commit | 7229b95cc036b978a526c77395c028320621765f (patch) | |
tree | 42d792ab7f0c8487eb362426abe4308125d23950 /libjava/java/net | |
parent | c9e4c7b5c4cd6a22bccadf61941aff97413e75fb (diff) | |
download | gcc-7229b95cc036b978a526c77395c028320621765f.zip gcc-7229b95cc036b978a526c77395c028320621765f.tar.gz gcc-7229b95cc036b978a526c77395c028320621765f.tar.bz2 |
InetAddress.java (getByName, [...]): Only perform security check when DNS lookups are required.
2006-09-01 Gary Benson <gbenson@redhat.com>
* java/net/InetAddress.java (getByName, getAllByName):
Only perform security check when DNS lookups are required.
From-SVN: r116621
Diffstat (limited to 'libjava/java/net')
-rw-r--r-- | libjava/java/net/InetAddress.java | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/libjava/java/net/InetAddress.java b/libjava/java/net/InetAddress.java index 6ca72fe..1c31294 100644 --- a/libjava/java/net/InetAddress.java +++ b/libjava/java/net/InetAddress.java @@ -592,14 +592,10 @@ public class InetAddress implements Serializable throws UnknownHostException { // If null or the empty string is supplied, the loopback address - // is returned. Note that this is permitted without a security check. + // is returned. if (hostname == null || hostname.length() == 0) return loopback; - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkConnect(hostname, -1); - // Assume that the host string is an IP address byte[] address = aton(hostname); if (address != null) @@ -623,6 +619,11 @@ public class InetAddress implements Serializable throw new UnknownHostException ("Address has invalid length"); } + // Perform security check before resolving + SecurityManager s = System.getSecurityManager(); + if (s != null) + s.checkConnect(hostname, -1); + // Try to resolve the host by DNS InetAddress result = new InetAddress(null, null); lookup (hostname, result, false); @@ -650,14 +651,10 @@ public class InetAddress implements Serializable throws UnknownHostException { // If null or the empty string is supplied, the loopback address - // is returned. Note that this is permitted without a security check. + // is returned. if (hostname == null || hostname.length() == 0) return new InetAddress[] {loopback}; - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkConnect(hostname, -1); - // Check if hostname is an IP address byte[] address = aton (hostname); if (address != null) @@ -667,6 +664,11 @@ public class InetAddress implements Serializable return result; } + // Perform security check before resolving + SecurityManager s = System.getSecurityManager(); + if (s != null) + s.checkConnect(hostname, -1); + // Try to resolve the hostname by DNS return lookup (hostname, null, true); } |