Fix braindead mistakes I made pointed out by Simo and
authorjra <jra@0c0555d6-39d7-0310-84fc-f1cc0bd64818>
Tue, 2 Oct 2007 20:39:41 +0000 (20:39 +0000)
committerjra <jra@0c0555d6-39d7-0310-84fc-f1cc0bd64818>
Tue, 2 Oct 2007 20:39:41 +0000 (20:39 +0000)
James (how did this compile ? :-).
Jeremy.

git-svn-id: svn+ssh://svn.samba.org/data/svn/samba/branches/SAMBA_3_2@25475 0c0555d6-39d7-0310-84fc-f1cc0bd64818

source/lib/interfaces.c

index 07abf4b..e5b9d87 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);