r25475: Fix braindead mistakes I made pointed out by Simo and
authorJeremy Allison <jra@samba.org>
Tue, 2 Oct 2007 20:39:41 +0000 (20:39 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:31:07 +0000 (12:31 -0500)
James (how did this compile ? :-).
Jeremy.

source/lib/interfaces.c

index 07abf4b1c6b559c908178d0e77eaf44f8f72080d..e5b9d874881f67ad179e6964d1bedab2e8437584 100644 (file)
@@ -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);