summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThadeu Lima de Souza Cascardo <cascardo@redhat.com>2016-03-30 18:12:17 -0300
committerBen Pfaff <blp@ovn.org>2016-03-30 16:59:48 -0700
commit3e6dc8b7a8250d21c3cba65cae482bb1524d89a4 (patch)
treea2d3641a03529995dadbf16e8ccb7c7982ac07d1 /lib
parentbeaa2b8702a20fa1f55e3b4c072dfe6fa394d6d1 (diff)
downloadopenvswitch-3e6dc8b7a8250d21c3cba65cae482bb1524d89a4.tar.gz
netdev: Verify ifa_addr is not NULL when iterating over getifaddrs.
Some point-to-point devices like TUN devices will not have an address, and while iterating over ifaddrs, its ifa_addr will be NULL. This patch fixes a crash when starting ovs-vswitchd on a system with such a device. Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com> Fixes: a8704b502785 ("tunneling: Handle multiple ip address for given device.") Cc: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/netdev.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/netdev.c b/lib/netdev.c
index 31998b39d..3e50694ac 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -1882,12 +1882,14 @@ 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 != NULL) {
+ int family;
- family = ifa->ifa_addr->sa_family;
- if (family == AF_INET || family == AF_INET6) {
- if (!strncmp(ifa->ifa_name, dev, IFNAMSIZ)) {
- cnt++;
+ family = ifa->ifa_addr->sa_family;
+ if (family == AF_INET || family == AF_INET6) {
+ if (!strncmp(ifa->ifa_name, dev, IFNAMSIZ)) {
+ cnt++;
+ }
}
}
}
@@ -1901,7 +1903,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 (strncmp(ifa->ifa_name, dev, IFNAMSIZ) || ifa->ifa_addr == NULL) {
continue;
}