chiark / gitweb /
noip.c (encode_inet_addr): Avoid collisions with wildcard addresses.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 2 May 2016 21:35:42 +0000 (22:35 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 2 May 2016 23:14:25 +0000 (00:14 +0100)
commitf6e0ea86fb3c3acddcbeddf625953aa1526daf35
tree2a72e00b1f45ccf2bf0a3648d1cb30eb0f187877
parentdc3956b3f2f9b13bbf93df2ed7295407cc90ab86
noip.c (encode_inet_addr): Avoid collisions with wildcard addresses.

If the caller is wanting to `encode' a currently floating socket (i.e.,
no explicit port number has been set and we're meant to pick one), then
make sure we pick a port number which doesn't collide with either the
chosen address /or/ the address-family wildcard address.  Otherwise, we
can get into the situation where process A listens on a floating socket
with a wildcard address, tells process B which port was allocated, and
then process B binds to localhost, tries to connect to A, and is stymied
because B actually allocated the same port number itself.

Really we ought to seed the RNG separately for each process.
noip.c