]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
use pack to construct the reply as Net::DNS just get it wrong
authorMark Andrews <marka@isc.org>
Wed, 29 Aug 2018 06:09:09 +0000 (16:09 +1000)
committerMark Andrews <marka@isc.org>
Fri, 31 Aug 2018 08:44:44 +0000 (18:44 +1000)
(cherry picked from commit feaf381adb6d2f75caebefff95ddd66511ac056c)

bin/tests/system/resolver/ans8/ans.pl

index 948859d69854e5c23cd3aa0a51891be17053b449..6d13110eef99d9d8c6a8e2ee24085802dfd03d72 100644 (file)
@@ -61,23 +61,15 @@ sub handleUDP {
        my $qclass = $questions[0]->qclass;
        my $id = $request->header->id;
 
-       my $packet = new Net::DNS::Packet();
-
-       $packet->header->qr(1);
-       $packet->header->aa(0);
-       $packet->header->id($id);
+       # don't use Net::DNS to construct the header only reply as early
+       # versions just get it completely wrong.
 
        if ($qname eq "truncated.no-questions") {
-               $packet->header->tc(1);
-       } else {
-               $packet->header->tc(0);
+               # QR, AA, TC
+               return (pack("nnnnnn", $id, 0x8600, 0, 0, 0, 0));
        }
-
-       # Net::DNS versions < 0.68 insert an ./ANY RR into the QUESTION section
-       # if the latter is empty.  Make sure Net::DNS version does not
-       # influence the return value of this function by returning the query ID
-       # and flags generated by Net::DNS with 8 zero bytes appended.
-       return substr($packet->data, 0, 4) . "\x00" x 8;
+       # QR, AA
+       return (pack("nnnnnn", $id, 0x8400, 0, 0, 0, 0));
 }
 
 sub handleTCP {