diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2011-03-15 23:01:56 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2011-03-15 23:01:56 +0000 |
commit | 78823a8e573b31fa78fc3e9d8e43ab429037e73e (patch) | |
tree | 699eeb22c79e237fb61e7ddecc6af64588c952f6 | |
parent | 58623414190c50acd270b42b5b61a60707842b02 (diff) | |
download | classpath-78823a8e573b31fa78fc3e9d8e43ab429037e73e.tar.gz |
PR42390: Add missing call to SecurityManager.checkConnect in connect(SocketAddress, int).
2011-03-14 Andrew John Hughes <ahughes@redhat.com>
PR classpath/42390
* java/net/Socket.java:
(connect(SocketAddress, int)): Add missing call
to SecurityManager.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | java/net/Socket.java | 11 |
2 files changed, 17 insertions, 1 deletions
@@ -1,3 +1,10 @@ +2011-03-14 Andrew John Hughes <ahughes@redhat.com> + + PR classpath/42390 + * java/net/Socket.java: + (connect(SocketAddress, int)): Add missing call + to SecurityManager. + 2011-03-15 Jeroen Frijters <jeroen@frijters.net> PR classpath/48131 diff --git a/java/net/Socket.java b/java/net/Socket.java index d61e81f5e..32b12e8b1 100644 --- a/java/net/Socket.java +++ b/java/net/Socket.java @@ -428,7 +428,9 @@ public class Socket * @exception IllegalBlockingModeException If this socket has an associated * channel, and the channel is in non-blocking mode * @exception SocketTimeoutException If the timeout is reached - * + * @throws SecurityException if the SocketAddress is an {@link InetSocketAddress} + * and a security manager is present which does not + * allow connections on the given host and port. * @since 1.4 */ public void connect(SocketAddress endpoint, int timeout) @@ -440,6 +442,13 @@ public class Socket if (! (endpoint instanceof InetSocketAddress)) throw new IllegalArgumentException("unsupported address type"); + SecurityManager sm = System.getSecurityManager(); + if (sm != null) + { + InetSocketAddress inetAddr = (InetSocketAddress) endpoint; + sm.checkConnect(inetAddr.getHostName(), inetAddr.getPort()); + } + // The Sun spec says that if we have an associated channel and // it is in non-blocking mode, we throw an IllegalBlockingModeException. // However, in our implementation if the channel itself initiated this |