summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--java/net/DatagramSocket.java22
2 files changed, 30 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index f90a6465a..014e17987 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
{