Fixes #22613
The fix is pretty simple – it’s legal to memcpy
between these types, you just can’t dereference members after a reinterpret_cast
. The memcpys
will be optimised away in any half decent compiler.
I chose to switch GetSockAddr/SetSockAddr
to accept sockaddr_storage
rather than sockaddr
so we can be sure we’re never reading/writing out of bounds. Essentially, struct sockaddr*
is old junk that we never want to deal with. Only hand those to the C APIs.