]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
4608. [func] DiG now warns about .local queries which are reserved
authorMark Andrews <marka@isc.org>
Mon, 24 Apr 2017 01:56:22 +0000 (11:56 +1000)
committerMark Andrews <marka@isc.org>
Mon, 24 Apr 2017 01:56:22 +0000 (11:56 +1000)
                        for Multicast DNS. [RT #44783]

CHANGES
bin/dig/dig.c
bin/tests/system/digdelv/tests.sh

diff --git a/CHANGES b/CHANGES
index d4c501e72f8687657df63314a78ec127b84a03fb..d28bdb75b54512b4410b9a4707905f6c2c032a88 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+4608.  [func]          DiG now warns about .local queries which are reserved
+                       for Multicast DNS. [RT #44783]
+
 4607.  [bug]           The memory context's malloced and maxmalloced counters
                        were being updated without the appropriate lock being
                        held.  [RT #44869]
index 51dcfa8e639512ae240730b816a198c2deb8601b..e38d03618000ef84a4db7e484525bed0f3ea2e6b 100644 (file)
@@ -465,6 +465,32 @@ printrdataset(dns_name_t *owner_name, dns_rdataset_t *rdataset,
 }
 #endif
 
+static isc_boolean_t
+isdotlocal(dns_message_t *msg) {
+       isc_result_t result;
+       static unsigned char local_ndata[] = { "\005local\0" };
+       static unsigned char local_offsets[] = { 0, 6 };
+       static dns_name_t local = {
+               DNS_NAME_MAGIC,
+               local_ndata, 7, 2,
+               DNS_NAMEATTR_READONLY | DNS_NAMEATTR_ABSOLUTE,
+               local_offsets, NULL,
+               {(void *)-1, (void *)-1},
+               {NULL, NULL}
+       };
+
+       for (result = dns_message_firstname(msg, DNS_SECTION_QUESTION);
+            result == ISC_R_SUCCESS;
+            result = dns_message_nextname(msg, DNS_SECTION_QUESTION))
+       {
+               dns_name_t *name = NULL;
+               dns_message_currentname(msg, DNS_SECTION_QUESTION, &name);
+               if (dns_name_issubdomain(name, &local))
+                       return (ISC_TRUE);
+       }
+       return (ISC_FALSE);
+}
+
 /*
  * Callback from dighost.c to print the reply from a server
  */
@@ -552,6 +578,12 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
                        printf(";; Got answer:\n");
 
                if (headers) {
+                       if (isdotlocal(msg)) {
+                               printf(";; WARNING: .local is reserved for "
+                                      "Multicast DNS\n;; You are currently "
+                                      "testing what happens when an mDNS "
+                                      "query is leaked to DNS\n");
+                       }
                        printf(";; ->>HEADER<<- opcode: %s, status: %s, "
                               "id: %u\n",
                               opcodetext[msg->opcode],
index 10628f8218a66fb4ea76247e2b57243550c33628..2dd820492b9960e2e33af80ca238eac2820be7cd 100644 (file)
@@ -425,6 +425,13 @@ if [ -x ${DIG} ] ; then
     echo "I:skipping 'dig +idnout' as IDN support is not enabled ($n)"
   fi
 
+  echo "I:checking that dig warns about .local queries ($n)"
+  ret=0
+  $DIG $DIGOPTS @10.53.0.3 local soa > dig.out.test$n 2>&1 || ret=1
+  grep ";; WARNING: .local is reserved for Multicast DNS" dig.out.test$n > /dev/null || ret=1
+  if [ $ret != 0 ]; then echo "I:failed"; fi
+  status=`expr $status + $ret`
+
 else
   echo "$DIG is needed, so skipping these dig tests"
 fi