From 989120d53e69adfc3fb86775a683147cb62d8d04 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 2 Oct 2007 20:39:41 +0000 Subject: r25475: Fix braindead mistakes I made pointed out by Simo and James (how did this compile ? :-). Jeremy. (This used to be commit ae8efc60aa1ddff795d16b1fb1bfe8cc392f49b3) --- source3/lib/interfaces.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/lib/interfaces.c b/source3/lib/interfaces.c index 07abf4b1c6..e5b9d87488 100644 --- a/source3/lib/interfaces.c +++ b/source3/lib/interfaces.c @@ -102,7 +102,7 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces) struct ifaddrs *ifptr = NULL; int total = 0; - if (getifaddrs(&ifp) < 0) { + if (getifaddrs(&iflist) < 0) { return -1; } @@ -111,6 +111,10 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces) ifptr != NULL && total < max_interfaces; ifptr = ifptr->ifa_next) { + if (!ifptr->ifa_addr || !ifptr->ifa_netmask) { + continue; + } + /* Skip ipv6 for now. */ if (ifptr->ifa_addr->sa_family != AF_INET) { continue; @@ -125,7 +129,7 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces) ((struct sockaddr_in *)ifptr->ifa_addr).sin_addr; ifaces[total].iface_netmask.netmask = - ((struct sockaddr_in *)ifptr->ifa_addr)->sin_addr; + ((struct sockaddr_in *)ifptr->ifa_netmask)->sin_addr; strncpy(ifaces[total].name, ifptr->ifa_name, sizeof(ifaces[total].name)-1); -- cgit