Blame SOURCES/0001-lldp_util-allow-for-null-ifa_addr-element.patch

78f543
From d0ed3f78b82e2e9a4e39451b7559804f19697533 Mon Sep 17 00:00:00 2001
78f543
From: Aaron Conole <aconole@redhat.com>
78f543
Date: Wed, 31 Jul 2019 16:03:09 -0400
78f543
Subject: [PATCH] lldp_util: allow for null ifa_addr element
78f543
78f543
The call to getifaddrs assumes that ifa_addr is always a valid pointer, but
78f543
getifaddrs is allowed to return a NULL value in that field.  Check that the
78f543
value is valid before attempting to access.
78f543
78f543
Signed-off-by: Aaron Conole <aconole@redhat.com>
78f543
---
78f543
 lldp_util.c | 6 ++++--
78f543
 1 file changed, 4 insertions(+), 2 deletions(-)
78f543
78f543
diff --git a/lldp_util.c b/lldp_util.c
78f543
index 32df768..c43abbf 100644
78f543
--- a/lldp_util.c
78f543
+++ b/lldp_util.c
78f543
@@ -1055,9 +1055,11 @@ int get_saddr6(const char *ifname, struct sockaddr_in6 *saddr)
78f543
 
78f543
 	rc = getifaddrs(&ifaddr);
78f543
 	if (rc == 0) {
78f543
+		rc = -1;
78f543
 		for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
78f543
-			if ((ifa->ifa_addr->sa_family == AF_INET6) &&
78f543
-			    (strncmp(ifa->ifa_name, ifname, IFNAMSIZ) == 0)) {
78f543
+			if (strncmp(ifa->ifa_name, ifname, IFNAMSIZ))
78f543
+				continue;
78f543
+			if (ifa->ifa_addr && (ifa->ifa_addr->sa_family == AF_INET6)) {
78f543
 				memcpy(saddr, ifa->ifa_addr, sizeof(*saddr));
78f543
 				rc = 0;
78f543
 				break;
78f543
-- 
78f543
2.21.0
78f543