]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3696. [bug] dig failed to handle AXFR style IXFR responses which
authorMark Andrews <marka@isc.org>
Sun, 5 Jan 2014 19:22:30 +0000 (06:22 +1100)
committerMark Andrews <marka@isc.org>
Sun, 5 Jan 2014 19:32:06 +0000 (06:32 +1100)
                        span multiple messages. [RT #35137]

(cherry picked from commit e9649ece3bf32ff43faea13c76bbba7813d7e139)

CHANGES
bin/dig/dighost.c
bin/dig/include/dig/dig.h
bin/tests/system/ixfr/clean.sh
bin/tests/system/ixfr/ns3/named.conf [new file with mode: 0644]
bin/tests/system/ixfr/setup.sh
bin/tests/system/ixfr/tests.sh

diff --git a/CHANGES b/CHANGES
index e2f4b6c1c860cc73a9a27fa2c617c2550cf7f65b..311b692884ac5796df9e666826b6782ba0077dce 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+3696.  [bug]           dig failed to handle AXFR style IXFR responses which
+                       span multiple messages. [RT #35137]
+
 3693.  [security]      memcpy was incorrectly called with overlapping
                        ranges resulting in malformed names being generated
                        on some platforms.  This could cause INSIST failures
index 0183945a7c7eb46197aade517d9320946d648d65..7bc05d1f3979a80402485796d3de95519990c2e5 100644 (file)
@@ -2148,6 +2148,7 @@ setup_lookup(dig_lookup_t *lookup) {
                query->rr_count = 0;
                query->msg_count = 0;
                query->byte_count = 0;
+               query->ixfr_axfr = ISC_FALSE;
                ISC_LIST_INIT(query->recvlist);
                ISC_LIST_INIT(query->lengthlist);
                query->sock = NULL;
@@ -2800,6 +2801,9 @@ check_for_more_data(dig_query_t *query, dns_message_t *msg,
        isc_boolean_t ixfr = query->lookup->rdtype == dns_rdatatype_ixfr;
        isc_boolean_t axfr = query->lookup->rdtype == dns_rdatatype_axfr;
 
+       if (ixfr)
+               axfr = query->ixfr_axfr;
+
        debug("check_for_more_data()");
 
        /*
@@ -2848,7 +2852,7 @@ check_for_more_data(dig_query_t *query, dns_message_t *msg,
                                        query->second_rr_rcvd = ISC_TRUE;
                                        query->second_rr_serial = 0;
                                        debug("got the second rr as nonsoa");
-                                       axfr = ISC_TRUE;
+                                       axfr = query->ixfr_axfr = ISC_TRUE;
                                        goto next_rdata;
                                }
 
index 0293934789a10d07eca0eddfc4329a17238501fd..374d3ff9a5efb439cf7e19b5cc481ee1826645b0 100644 (file)
@@ -202,6 +202,7 @@ struct dig_query {
        isc_uint32_t second_rr_serial;
        isc_uint32_t msg_count;
        isc_uint32_t rr_count;
+       isc_boolean_t ixfr_axfr;
        char *servname;
        char *userarg;
        isc_bufferlist_t sendlist,
index 4950febcf421e4e96acbe88d8a1ad3dec67530cc..57b23039ba2f8ace9bc10512af8a05dfdf571d11 100644 (file)
@@ -19,3 +19,5 @@
 
 rm -f ns1/named.conf ns1/myftp.db
 rm -f */named.memstats
+rm -f dig.out
+rm -f ns3/large.db
diff --git a/bin/tests/system/ixfr/ns3/named.conf b/bin/tests/system/ixfr/ns3/named.conf
new file mode 100644 (file)
index 0000000..5bbf58f
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* $Id: named.conf,v 1.3 2011/09/07 23:46:27 tbox Exp $ */
+
+options {
+        query-source address 10.53.0.3;
+        notify-source 10.53.0.3;
+        transfer-source 10.53.0.3;
+       allow-transfer { any; };
+        port 5300;
+        pid-file "named.pid";
+        listen-on { 10.53.0.3; };
+        listen-on-v6 { none; };
+        recursion no;
+        notify yes;
+};
+
+key rndc_key {
+        secret "1234abcd8765";
+        algorithm hmac-md5;
+};
+
+controls {
+        inet 10.53.0.3 port 9953 allow { any; } keys { rndc_key; };
+};
+
+view "primary" {
+       zone "large" IN {
+               type master;
+               file "large.db";
+       };
+};
index 1935918d42b2305b5c6b4654059314e9362945fc..d7c8383d0204696567b17868148fb5acb7f3d872 100644 (file)
@@ -41,3 +41,7 @@ controls {
        inet 10.53.0.1 port 9953 allow { any; } keys { rndc_key; };
 };
 EOF
+
+# Setup initial db files for ns3
+sh ../genzone.sh 3 > ns3/large.db
+awk 'END { for (i = 0; i < 10000; i++) printf("record%d 10 IN TXT this is record %d\n", i, i) }' < /dev/null >> ns3/large.db
index 64752d8ca5ddd9d9ef1d92f08a92b83d5ceccd20..28099856963bb3330fb34c3b149d635a05a647b8 100644 (file)
@@ -137,5 +137,17 @@ $DIGCMD nil. TXT | grep 'fallback AXFR' >/dev/null || {
     status=1
 }
 
+echo "I:testing DiG's handling of a multi message AXFR style IXFR response" 
+(
+(sleep 10 && kill $$) 2>/dev/null &
+sub=$!
+$DIG ixfr=0 large -p 5300 @10.53.0.3 > dig.out
+kill $sub
+)
+lines=`grep hostmaster.large dig.out | wc -l`
+test ${lines:-0} -eq 2 || { echo "I:failed"; status=1; }
+messages=`sed -n 's/^;;.*messages \([0-9]*\),.*/\1/p' dig.out`
+test ${messages:-0} -gt 1 || { echo "I:failed"; status=1; }
+
 echo "I:exit status: $status"
 exit $status