]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
1209. [bug] Dig, host, nslookup were not checking the message ids
authorMark Andrews <marka@isc.org>
Thu, 21 Feb 2002 04:48:00 +0000 (04:48 +0000)
committerMark Andrews <marka@isc.org>
Thu, 21 Feb 2002 04:48:00 +0000 (04:48 +0000)
                       on the responses. [RT #2454]

CHANGES
bin/dig/dighost.c

diff --git a/CHANGES b/CHANGES
index 96d2e8e95886db2af65f89765bd8187e20fc0e17..303d892ce22e6f039348e044a64bac76b9c0eff9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+1209.  [bug]           Dig, host, nslookup were not checking the message ids
+                       on the responses. [RT #2454]
+
 1208.  [bug]           dns_master_load*() failed to log a error message if
                        an error was detected when parsing the ownername of
                        a record.  [RT #2448]
index ce2337a7afe73373d2d3b1717ac1d0d73ab3db16..b89c5e8cd968aa052f128490a2af7844914c708f 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: dighost.c,v 1.240 2002/02/20 03:32:56 marka Exp $ */
+/* $Id: dighost.c,v 1.241 2002/02/21 04:48:00 marka Exp $ */
 
 /*
  * Notice to programmers:  Do not use this code as an example of how to
@@ -2118,6 +2118,8 @@ recv_done(isc_task_t *task, isc_event_t *event) {
        dig_lookup_t *n, *l;
        isc_boolean_t docancel = ISC_FALSE;
        unsigned int parseflags;
+       dns_messageid_t id;
+       unsigned int msgflags;
 
        UNUSED(task);
        INSIST(!free_now);
@@ -2172,6 +2174,36 @@ recv_done(isc_task_t *task, isc_event_t *event) {
 
        b = ISC_LIST_HEAD(sevent->bufferlist);
        ISC_LIST_DEQUEUE(sevent->bufferlist, &query->recvbuf, link);
+
+       result = dns_message_peekheader(b, &id, &msgflags);
+       if (result != ISC_R_SUCCESS || l->sendmsg->id != id) {
+               if (l->tcp_mode) {
+                       if (result == ISC_R_SUCCESS)
+                               printf(";; ERROR: ID mismatch\n");
+                       else
+                               printf(";; ERROR: runt message\n");
+                       isc_event_free(&event);
+                       clear_query(query);
+                       check_next_lookup(l);
+                       UNLOCK_LOOKUP;
+                       return;
+               }
+               if (result == ISC_R_SUCCESS)
+                       printf(";; Warning: ID mismatch\n");
+               else
+                       printf(";; Warning: runt message received\n");
+               isc_buffer_invalidate(&query->recvbuf);
+               isc_buffer_init(&query->recvbuf, query->recvspace, COMMSIZE);
+               ISC_LIST_ENQUEUE(query->recvlist, &query->recvbuf, link);
+               result = isc_socket_recvv(query->sock, &query->recvlist, 1,
+                                         global_task, recv_done, query);
+               check_result(result, "isc_socket_recvv");
+               recvcount++;
+               isc_event_free(&event);
+               UNLOCK_LOOKUP;
+               return;
+       }
+
        result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &msg);
        check_result(result, "dns_message_create");