Browse Source

[trac80] fixed the same type of bug for explicit DNAME query.

This should not cause a crash, but returned an incorrect result.
JINMEI Tatuya 14 years ago
parent
commit
f1f8b24ea7
2 changed files with 11 additions and 1 deletions
  1. 1 1
      src/lib/datasrc/data_source.cc
  2. 10 0
      src/lib/datasrc/tests/datasrc_unittest.cc

+ 1 - 1
src/lib/datasrc/data_source.cc

@@ -931,7 +931,7 @@ DataSrc::doQuery(Query& q) {
              ((task->qtype == RRType::NSEC() ||
                task->qtype == RRType::DS() ||
                task->qtype == RRType::DNAME()) &&
-              data.findRRset(task->qtype, task->qclass)))) {
+              findRRsetFromList(data, task->qtype)))) {
             task->flags &= ~REFERRAL;
         }
 

+ 10 - 0
src/lib/datasrc/tests/datasrc_unittest.cc

@@ -198,6 +198,16 @@ TEST_F(DataSrcTest, queryClassAnyDNAME) {
                 "www.sql1.example.com. 3600 IN A 192.0.2.2\n",
                 msg.beginSection(Message::SECTION_ANSWER),
                 msg.endSection(Message::SECTION_ANSWER));
+
+    // Also check the case of explicit DNAME query.
+    msg.clear(Message::PARSE);
+    createAndProcessQuery(Name("dname.example.com"), RRClass::ANY(),
+                          RRType::DNAME(), false);
+    headerCheck(msg, qid, Rcode::NOERROR(), opcodeval,
+                QR_FLAG | AA_FLAG | RD_FLAG, 1, 1, 3, 3);
+    rrsetsCheck("dname.example.com. 3600 IN DNAME sql1.example.com.\n",
+                msg.beginSection(Message::SECTION_ANSWER),
+                msg.endSection(Message::SECTION_ANSWER));
 }
 
 TEST_F(DataSrcTest, queryClassAnyCNAME) {