1From e501d58e9ec6cb6e19a682d425fa638069585fbc Mon Sep 17 00:00:00 2001
2Message-ID: <e501d58e9ec6cb6e19a682d425fa638069585fbc.1687508149.git.stefan@agner.ch>
3In-Reply-To: <e136dcdcdd93ef32ada981e89c195905eb809eea.1687508149.git.stefan@agner.ch>
4References: <e136dcdcdd93ef32ada981e89c195905eb809eea.1687508149.git.stefan@agner.ch>
5From: Stefan Agner <[email protected]>
6Date: Fri, 23 Jun 2023 10:10:00 +0200
7Subject: [PATCH] Handle interface without `ifa_addr`
8
9It seems that certain interface types may have `ifa_addr` set to null.
10Handle this case gracefully.
11
12Signed-off-by: Stefan Agner <[email protected]>
13---
14 mDNSPosix/mDNSPosix.c | 4 +++-
15 1 file changed, 3 insertions(+), 1 deletion(-)
16
17diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c
18index 89e108f..2056871 100644
19--- a/mDNSPosix/mDNSPosix.c
20+++ b/mDNSPosix/mDNSPosix.c
21@@ -1895,6 +1895,7 @@ mDNSlocal void InterfaceChangeCallback(int fd, void *context)
22 	    continue;
23
24         if ((ifa_loop4 == NULL) &&
25+            ((*ifi)->ifa_addr != NULL) &&
26             ((*ifi)->ifa_addr->sa_family == AF_INET) &&
27             ((*ifi)->ifa_flags & IFF_UP) &&
28             ((*ifi)->ifa_flags & IFF_LOOPBACK))
29@@ -1903,7 +1904,8 @@ mDNSlocal void InterfaceChangeCallback(int fd, void *context)
30             continue;
31         }
32
33-        if (     (((*ifi)->ifa_addr->sa_family == AF_INET)
34+        if (     ((*ifi)->ifa_addr != NULL) &&
35+                 (((*ifi)->ifa_addr->sa_family == AF_INET)
36 #if HAVE_IPV6
37                   || ((*ifi)->ifa_addr->sa_family == AF_INET6)
38 #endif
39--
402.41.0
41
42