Avoid Segv by testing address field before using it.
authorJohn Light <john.j.light@intel.com>
Thu, 30 Jul 2015 22:14:07 +0000 (15:14 -0700)
committerErich Keane <erich.keane@intel.com>
Mon, 10 Aug 2015 16:33:33 +0000 (16:33 +0000)
sIssue reported off dev list by Gabriel Schulhof.

Change-Id: Ifa529da59fb784fd5cdef6ca333635cf99ed1f59
Signed-off-by: John Light <john.j.light@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2160
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/src/ip_adapter/linux/caipnwmonitor.c

index b4ca971..a5fb789 100644 (file)
@@ -63,6 +63,10 @@ u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex)
     struct ifaddrs *ifa = NULL;
     for (ifa = ifp; ifa; ifa = ifa->ifa_next)
     {
+        if (!ifa->ifa_addr)
+        {
+            continue;
+        }
         int family = ifa->ifa_addr->sa_family;
         if ((ifa->ifa_flags & IFF_LOOPBACK) || (AF_INET != family && AF_INET6 != family))
         {