]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3876: mDNS support segfault when using --disable-ipv6
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 9 Jul 2013 05:31:57 +0000 (17:31 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 9 Jul 2013 05:31:57 +0000 (17:31 +1200)
When IPv6 is disabled the mDNS IPv6 multicast group gets rejected by
idnsAddnameserver() resulting in invalid pointers for the remaining
mDNS NS setup operations.

Convert the hard-coded mDNS nameserver count to dynamic global count and
elide the relevant NS when IPv6 support disabled.

src/dns_internal.cc

index 92965e1fb69b3d77248cd007378e99d5c28d87a3..326547a3ef061647a95457024521d8dc3332838c 100644 (file)
@@ -196,6 +196,7 @@ static ns *nameservers = NULL;
 static sp *searchpath = NULL;
 static int nns = 0;
 static int nns_alloc = 0;
+static int nns_mdns_count = 0;
 static int npc = 0;
 static int npc_alloc = 0;
 static int ndots = 1;
@@ -276,16 +277,21 @@ idnsCheckMDNS(idns_query *q)
 static void
 idnsAddMDNSNameservers()
 {
-#define MDNS_RESOLVER_COUNT 2
+    nns_mdns_count=0;
 
     // mDNS resolver addresses are explicit multicast group IPs
-    idnsAddNameserver("FF02::FB");
-    nameservers[nns-1].S.port(5353);
-    nameservers[nns-1].mDNSResolver = true;
+    if (Ip::EnableIpv6) {
+        idnsAddNameserver("FF02::FB");
+        nameservers[nns-1].S.port(5353);
+        nameservers[nns-1].mDNSResolver = true;
+        ++nns_mdns_count;
+    }
 
     idnsAddNameserver("224.0.0.251");
     nameservers[nns-1].S.port(5353);
     nameservers[nns-1].mDNSResolver = true;
+
+    ++nns_mdns_count;
 }
 
 static void
@@ -956,7 +962,7 @@ idnsSendQuery(idns_query * q)
     do {
         // only use mDNS resolvers for mDNS compatible queries
         if (!q->permit_mdns)
-            nsn = MDNS_RESOLVER_COUNT + q->nsends % (nns-MDNS_RESOLVER_COUNT);
+            nsn = nns_mdns_count + q->nsends % (nns-nns_mdns_count);
         else
             nsn = q->nsends % nns;