Fix possible SIGSEGV in bpf.c

This commit is contained in:
Simon Kelley
2025-02-08 22:58:42 +00:00
parent bceab45dbe
commit 535be2f5d3

View File

@@ -125,12 +125,11 @@ int iface_enumerate(int family, void *parm, callback_t callback)
#endif #endif
for (addrs = head; addrs; addrs = addrs->ifa_next) for (addrs = head; addrs; addrs = addrs->ifa_next)
{
if (addrs->ifa_addr->sa_family == family)
{ {
int iface_index = if_nametoindex(addrs->ifa_name); int iface_index = if_nametoindex(addrs->ifa_name);
if (iface_index == 0 || !addrs->ifa_addr || if (iface_index == 0 || !addrs->ifa_addr ||
addrs->ifa_addr->sa_family != family ||
(!addrs->ifa_netmask && family != AF_LINK)) (!addrs->ifa_netmask && family != AF_LINK))
continue; continue;
@@ -228,7 +227,6 @@ int iface_enumerate(int family, void *parm, callback_t callback)
} }
#endif #endif
} }
}
ret = 1; ret = 1;