For some network interface configurations, it is possible for
entries on the address list returned by getifaddrs() to have
ifa->ifa_addr set to NULL. Add checks to avoid dereferencing
ifa->ifa_addr in this case.

Fixes: a8704b502785 ("tunneling: Handle multiple ip address for given device.")
Signed-off-by: Lance Richardson <lrich...@redhat.com>
---
 lib/netdev.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/netdev.c b/lib/netdev.c
index 31998b3..a57c238 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -1884,6 +1884,10 @@ netdev_get_addrs(const char dev[], struct in6_addr 
**paddr,
     for (ifa = if_addr_list; ifa; ifa = ifa->ifa_next) {
         int family;
 
+        if (!ifa->ifa_addr) {
+            continue;
+        }
+
         family = ifa->ifa_addr->sa_family;
         if (family == AF_INET || family == AF_INET6) {
             if (!strncmp(ifa->ifa_name, dev, IFNAMSIZ)) {
@@ -1901,7 +1905,7 @@ netdev_get_addrs(const char dev[], struct in6_addr 
**paddr,
     for (ifa = if_addr_list; ifa; ifa = ifa->ifa_next) {
         int family;
 
-        if (strncmp(ifa->ifa_name, dev, IFNAMSIZ)) {
+        if (!ifa->ifa_addr || strncmp(ifa->ifa_name, dev, IFNAMSIZ)) {
             continue;
         }
 
-- 
2.5.5

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to