1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

lws_interface_to_sa: confirm getifaddrs worked

We don't actually check that it provided results... return diags and
that the interface is usable if it didn't.

Also explicitly check ifa_name for being NULL, since it seems some
platforms can do that even with an ifa_addr (thanks to Jed)
This commit is contained in:
Andy Green 2020-07-29 11:14:37 +01:00
parent 5be8ff27d5
commit ddcbb6fa80

View file

@ -203,9 +203,13 @@ lws_interface_to_sa(int ipv6, const char *ifname, struct sockaddr_in *addr,
struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)addr;
#endif
getifaddrs(&ifr);
if (getifaddrs(&ifr)) {
lwsl_err("%s: unable to getifaddrs: errno %d\n", __func__, errno);
return LWS_ITOSA_USABLE;
}
for (ifc = ifr; ifc != NULL && rc; ifc = ifc->ifa_next) {
if (!ifc->ifa_addr)
if (!ifc->ifa_addr || !ifc->ifa_name)
continue;
lwsl_debug(" interface %s vs %s (fam %d) ipv6 %d\n",