netmask returned by getifaddrs may not have address family set on macOS

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2019-01-18 12:13:39 +01:00
parent c72964027e
commit 27bf91fae6

View file

@ -43,6 +43,11 @@ copyaddr(os_ifaddrs_t **ifap, const struct ifaddrs *sys_ifa)
{
err = errno;
}
/* Seen on macOS using OpenVPN: netmask without an address family,
in which case copy it from the interface address */
if (ifa->addr && ifa->netmask && ifa->netmask->sa_family == 0) {
ifa->netmask->sa_family = ifa->addr->sa_family;
}
}
if (err == 0) {