chiark / gitweb /
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.