]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
When using +qr in dig print the data of the current query
authorAram Sargsyan <aram@isc.org>
Thu, 31 Mar 2022 14:33:49 +0000 (14:33 +0000)
committerAram Sargsyan <aram@isc.org>
Tue, 5 Apr 2022 11:20:41 +0000 (11:20 +0000)
In `send_udp()` and `launch_next_query()` functions, when calling
`dighost_printmessage()` to print detailed information about the
sent query, dig always prints the data of the first query in the
lookup's queries list.

The first query in the list can be already finished, having its handles
freed, and accessing this information results in assertion failure.

Print the current query's information instead.

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

index 166358b34802eb008996d1ea25a2cf1b9e45aa4f..35d29eefd8d6042793bc6a8cd67bd8f9bff1a0d2 100644 (file)
@@ -3080,10 +3080,9 @@ send_udp(dig_query_t *query) {
        debug("sendcount=%" PRIuFAST32, isc_refcount_current(&sendcount));
 
        /* XXX qrflag, print_query, etc... */
-       if (!ISC_LIST_EMPTY(query->lookup->q) && query->lookup->qr) {
+       if (query->lookup->qr) {
                extrabytes = 0;
-               dighost_printmessage(ISC_LIST_HEAD(query->lookup->q),
-                                    &query->lookup->renderbuf,
+               dighost_printmessage(query, &query->lookup->renderbuf,
                                     query->lookup->sendmsg, true);
                if (query->lookup->stats) {
                        print_query_size(query);
@@ -3426,10 +3425,10 @@ launch_next_query(dig_query_t *query) {
                      isc_refcount_current(&sendcount));
 
                /* XXX qrflag, print_query, etc... */
-               if (!ISC_LIST_EMPTY(l->q) && l->qr) {
+               if (l->qr) {
                        extrabytes = 0;
-                       dighost_printmessage(ISC_LIST_HEAD(l->q), &l->renderbuf,
-                                            l->sendmsg, true);
+                       dighost_printmessage(query, &l->renderbuf, l->sendmsg,
+                                            true);
                        if (l->stats) {
                                print_query_size(query);
                        }
index 6c28ac7bca4e5447f36e21c1da3ec3c7e88025fd..767e33f8e6674199efc8483df48e404fb03ca841 100644 (file)
@@ -1081,6 +1081,15 @@ if [ -x "$DIG" ] ; then
   grep -F ";; No acceptable nameservers" dig.out.test$n > /dev/null || ret=1
   if [ $ret -ne 0 ]; then echo_i "failed"; fi
   status=$((status+ret))
+
+  # See [GL #3244] for more information
+  n=$((n+1))
+  echo_i "check that dig handles printing query information with +qr and +y when multiple queries are involved (including a failed query) ($n)"
+  ret=0
+  dig_with_opts +timeout=1 +qr +y @127.0.0.1 @10.53.0.3 a.example > dig.out.test$n 2>&1 || ret=1
+  grep -F "IN A 10.0.0.1" dig.out.test$n > /dev/null || ret=1
+  if [ $ret -ne 0 ]; then echo_i "failed"; fi
+  status=$((status+ret))
 else
   echo_i "$DIG is needed, so skipping these dig tests"
 fi