]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Be lenient and accept imgw.pl malformed packet (like BIND).
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 8 Nov 2010 18:32:55 +0000 (18:32 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 8 Nov 2010 18:32:55 +0000 (18:32 +0000)
git-svn-id: file:///svn/unbound/trunk@2339 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
testcode/unitmsgparse.c
testdata/test_packets.8 [new file with mode: 0644]
util/data/msgparse.c

index 36bcdcc459f162d85d5df4d984f27daf410dd7f0..6dfa5e8e188ea5c9b115a7c6a417e0a0833f53c0 100644 (file)
@@ -1,6 +1,7 @@
 8 November 2010: Wouter
        - release tag 1.4.7.
        - trunk is version 1.4.8.
+       - Be lenient and accept imgw.pl malformed packet (like BIND).
 
 5 November 2010: Wouter
        - do not synthesize a CNAME message from cache for qtype DS.
index 1d4d1a3f291100d2255f2ec3ed3292118dc90328..d5ce78757a81d4af41ec612f066a37474a789120 100644 (file)
@@ -53,6 +53,8 @@
 
 /** verbose message parse unit test */
 static int vbmp = 0;
+/** do not accept formerr */
+static int check_formerr_gone = 0;
 /** if matching within a section should disregard the order of RRs. */
 static int matches_nolocation = 0;
 /** see if RRSIGs are properly matched to RRsets. */
@@ -415,10 +417,12 @@ testpkt(ldns_buffer* pkt, struct alloc_cache* alloc, ldns_buffer* out,
        if(ret != 0) {
                if(vbmp) printf("parse code %d: %s\n", ret, 
                        ldns_lookup_by_id(ldns_rcodes, ret)->name);
-               if(ret == LDNS_RCODE_FORMERR)
+               if(ret == LDNS_RCODE_FORMERR) {
+                       unit_assert(!check_formerr_gone);
                        checkformerr(pkt);
+               }
                unit_assert(ret != LDNS_RCODE_SERVFAIL);
-       } else {
+       } else if(!check_formerr_gone) {
                const size_t lim = 512;
                ret = reply_info_encode(&qi, rep, id, flags, out, timenow,
                        region, 65535, (int)(edns.bits & EDNS_DO) );
@@ -599,6 +603,10 @@ void msgparse_test(void)
        check_rrsigs = 0;
        matches_nolocation = 0; 
 
+       check_formerr_gone = 1;
+       testfromdrillfile(pkt, &alloc, out, "testdata/test_packets.8");
+       check_formerr_gone = 0;
+
        /* cleanup */
        alloc_clear(&alloc);
        alloc_clear(&super_a);
diff --git a/testdata/test_packets.8 b/testdata/test_packets.8
new file mode 100644 (file)
index 0000000..de6c046
--- /dev/null
@@ -0,0 +1,13 @@
+; Test that FORMERR no longer happens.
+;-- next packet --
+; bad packet, had arcount=1 but EDNS record is missing.
+; from imgw.pl.  BIND accepts it (but dig notes 'it is malformed').
+; therefore we leniently accept this.
+; header
+75D684100001000200000001
+; qd section
+04696D677702706C0000010001
+; answer section 
+04696D677702706C000001000100000E100004C3BB560E
+04696D677702706C000001000100000E100004C3BB560D
+
index 163228339c113e852be7510559dcf635774c3aab..68ca4ebab9c2f026ddf923d2d8b9cda99c440ef5 100644 (file)
@@ -903,8 +903,11 @@ parse_packet(ldns_buffer* pkt, struct msg_parse* msg, struct regional* region)
        if((ret = parse_section(pkt, msg, region, LDNS_SECTION_AUTHORITY,
                msg->nscount, &msg->ns_rrsets)) != 0)
                return ret;
-       if((ret = parse_section(pkt, msg, region, LDNS_SECTION_ADDITIONAL, 
-               msg->arcount, &msg->ar_rrsets)) != 0)
+       if(ldns_buffer_remaining(pkt) == 0 && msg->arcount == 1) {
+               /* BIND accepts leniently that an EDNS record is missing.
+                * so, we do too. */
+       } else if((ret = parse_section(pkt, msg, region,
+               LDNS_SECTION_ADDITIONAL, msg->arcount, &msg->ar_rrsets)) != 0)
                return ret;
        /* if(ldns_buffer_remaining(pkt) > 0) { */
                /* there is spurious data at end of packet. ignore */