On 04/10/2019 16:25, Florian Weimer wrote:
:
@@ -873,10 +873,15 @@
synchronized (stateLock) {
ensureOpen();
if (state == ST_CONNECTED)
throw new AlreadyConnectedException();
+ // ensure that the socket is bound
+ if (localAddress == null) {
+ bindInternal(null);
+ }
+
int n = Net.connect(family,
fd,
isa.getAddress(),
isa.getPort());
if (n <= 0)
Doesn't it introduce a race condition where the socket has a port and
queue packets, but the kernel will not perform source address checking
because it is unconnected?
The socket is unbound, this change to the connect method in Daniel's
patch just binds it before connecting. The kernel will do this anyway so
it's not strictly needed here (at least for the case that the connect
succeeds_. There's a completely unrelated issue with the security
manager (SM) checkListen being consulted when binding but that is a
topic for another thread.
-Alan