diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | java/net/DatagramSocket.java | 22 |
2 files changed, 30 insertions, 1 deletions
@@ -1,3 +1,12 @@ +2012-02-06 Andrew John Hughes <ahughes@redhat.com> + + PR classpath/42390 + * java/net/DatagramSocket.java: + (connect(InetAddress,int)): Add missing security + checks which OpenJDK performs and we don't. It's + possible to initialise a DatagramSocket with null + so we should also ensure we are bound. + 2012-02-01 Andrew John Hughes <ahughes@redhat.com> * resource/gnu/java/locale/LocaleInformation.properties, diff --git a/java/net/DatagramSocket.java b/java/net/DatagramSocket.java index 6ca9c42fe..baa572ce3 100644 --- a/java/net/DatagramSocket.java +++ b/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 { |