netaddr_t !(AF_INET || AF_INET6) handling
While looking isc_netaddr_fromsockaddr()
code, I found out that it can handle AF_UNIX sockets as well, but most of the code that process the resulting struct isc_netaddr
only takes care of AF_INET
or AF_INET6
classes in a way that would process of reading arbitrary bytes from struct sockaddr_un
path.
The code using netaddr_t should be changed to properly check for values that makes sense, e.g. from:
if (family == AF_INET6) {
// IPv6 code
} else {
// IPv4 code
}
to
if (family == AF_INET6) {
// IPv6 code
} else if (family == AF_INET) {
// IPv4 code
} else {
// handle unknown AF_
}
That would also allow us to remove the hard INSIST(0)
from default branch in isc_netaddr_fromsockaddr
and change it to warning + setting family to AF_UNSPEC on an unknown socket.