mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8240533: Inconsistent Exceptions are thrown by DatagramSocket and DatagramChannel when sending a DatagramPacket to port 0
Fix adds checks for port == 0 to the send and connect methods in DatagramSocket and DatagramChannelImpl Reviewed-by: alanb, chegar, dfuchs, lancea
This commit is contained in:
parent
e53ae5ae63
commit
378aef32ab
6 changed files with 560 additions and 0 deletions
|
@ -188,6 +188,9 @@ public class DatagramSocket implements java.io.Closeable {
|
|||
}
|
||||
}
|
||||
|
||||
if (port == 0) {
|
||||
throw new SocketException("Can't connect to port 0");
|
||||
}
|
||||
if (!isBound())
|
||||
bind(new InetSocketAddress(0));
|
||||
|
||||
|
@ -772,6 +775,9 @@ public class DatagramSocket implements java.io.Closeable {
|
|||
packetPort);
|
||||
}
|
||||
}
|
||||
if (packetPort == 0) {
|
||||
throw new SocketException("Can't send to port 0");
|
||||
}
|
||||
} else {
|
||||
// we're connected
|
||||
if (packetAddress == null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue