1From 1cc54320306e07c1fc0eed98e7fbcbb07a2f3b28 Mon Sep 17 00:00:00 2001
2From: Stefan Agner <stefan@agner.ch>
3Date: Fri, 23 Jun 2023 10:10:00 +0200
4Subject: [PATCH] Handle interface without `ifa_addr`
5
6It seems that certain interface types may have `ifa_addr` set to null.
7Handle this case gracefully.
8
9Upstream-Status: Submitted [https://github.com/apple-oss-distributions/mDNSResponder/pull/2/commits/11b410d4d683c90e693c40315997bb3e8ec90e9a]
10
11Signed-off-by: Stefan Agner <stefan@agner.ch>
12Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
13---
14 mDNSPosix/mDNSPosix.c | 4 +++-
15 1 file changed, 3 insertions(+), 1 deletion(-)
16
17Index: mDNSResponder/mDNSPosix/mDNSPosix.c
18===================================================================
19--- mDNSResponder.orig/mDNSPosix/mDNSPosix.c
20+++ mDNSResponder/mDNSPosix/mDNSPosix.c
21@@ -1895,6 +1895,7 @@ mDNSlocal void InterfaceChangeCallback(i
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(i
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