summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/lib/interfaces.c8
1 files changed, 6 insertions, 2 deletions
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);