diff options
| author | gandalf <gandalf@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-23 15:19:26 +0000 |
|---|---|---|
| committer | gandalf <gandalf@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-23 15:19:26 +0000 |
| commit | 5c7411981584e487ac41794feb98a66df9fd6fcb (patch) | |
| tree | febe3d4d4c0c994db223fee8e819bde6582494c9 /libjava/classpath/java/net | |
| parent | 112dfe9f689af01c2dd00e0f153fc25d69095b6c (diff) | |
| download | ppe42-gcc-5c7411981584e487ac41794feb98a66df9fd6fcb.tar.gz ppe42-gcc-5c7411981584e487ac41794feb98a66df9fd6fcb.zip | |
Merge GNU Classpath 0.99 into libjava.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@185741 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/java/net')
| -rw-r--r-- | libjava/classpath/java/net/DatagramSocket.java | 22 | ||||
| -rw-r--r-- | libjava/classpath/java/net/Socket.java | 11 |
2 files changed, 31 insertions, 2 deletions
diff --git a/libjava/classpath/java/net/DatagramSocket.java b/libjava/classpath/java/net/DatagramSocket.java index 6ca9c42fea6..baa572ce39f 100644 --- a/libjava/classpath/java/net/DatagramSocket.java +++ b/libjava/classpath/java/net/DatagramSocket.java @@ -525,7 +525,27 @@ public class DatagramSocket SecurityManager sm = System.getSecurityManager(); if (sm != null) - sm.checkConnect(address.getHostAddress(), port); + { + if (address.isMulticastAddress()) + sm.checkMulticast(address); + else + { + sm.checkConnect(address.getHostAddress(), port); + sm.checkAccept(address.getHostAddress(), port); + } + } + + if (!isBound()) + { + try + { + bind(new InetSocketAddress(0)); + } + catch (SocketException e) + { + throw new Error("Binding socket failed.", e); + } + } try { diff --git a/libjava/classpath/java/net/Socket.java b/libjava/classpath/java/net/Socket.java index d61e81f5e42..32b12e8b1bf 100644 --- a/libjava/classpath/java/net/Socket.java +++ b/libjava/classpath/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 |

