Browse Source

- handle wildcard queries correctly when there is no data of the requested type
- handle wildcard queries correctly when there is a wildcard CNAME
- added a unit test for the nodata case (still need to do one for the CNAME)


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1317 e5f2f494-b856-4b98-b285-d166d9295462

Evan Hunt 15 years ago
parent
commit
943f1cdb07

+ 12 - 7
src/lib/auth/data_source.cc

@@ -430,14 +430,19 @@ tryWildcard(Query& q, QueryTaskPtr task, const DataSrc* ds,
 
     for (int i = 1; i <= diff; ++i) {
         const Name& wname(star.concatenate(task->qname.split(i, nlen - i)));
-        QueryTask newtask(wname, task->qclass, task->qtype,
-                          QueryTask::SIMPLE_QUERY); 
+        QueryTask newtask(wname, task->qclass, task->qtype, Section::ANSWER(),
+                          QueryTask::AUTH_QUERY); 
         result = doQueryTask(ds, zonename, newtask, wild);
-        if (result == DataSrc::SUCCESS &&
-            (newtask.flags == 0 || (newtask.flags & DataSrc::CNAME_FOUND))) {
-            rflags = newtask.flags;
-            found = true;
-            break;
+        if (result == DataSrc::SUCCESS) {
+            if (newtask.flags == 0 || (newtask.flags & DataSrc::CNAME_FOUND)) {
+                rflags = newtask.flags;
+                found = true;
+                break;
+            } else if ((newtask.flags & DataSrc::TYPE_NOT_FOUND) != 0) {
+                task->flags &= ~DataSrc::NAME_NOT_FOUND;
+                task->flags |= DataSrc::TYPE_NOT_FOUND;
+                break;
+            }
         }
     }
 

+ 8 - 0
src/lib/auth/tests/datasrc_unittest.cc

@@ -252,6 +252,14 @@ TEST_F(DataSrcTest, Wildcard) {
     EXPECT_TRUE(it->isLast());
 }
 
+TEST_F(DataSrcTest, WildcardNodata) {
+
+    // Check that a query for a data type not covered by the wildcard
+    // returns NOERROR
+    readAndProcessQuery(msg, "testdata/q_wild2");
+    headerCheck(msg, Rcode::NOERROR(), true, true, true, 0, 2, 0);
+}
+
 TEST_F(DataSrcTest, AuthDelegation) {
     readAndProcessQuery(msg, "testdata/q_sql1");
 

+ 4 - 0
src/lib/auth/tests/testdata/q_wild2

@@ -0,0 +1,4 @@
+# www.wild.example.com/A (wildcard)
+  d8 ef 01 00 00 01 00 00 00 00 00 00 03 77 77 77
+  04 77 69 6c 64 07 65 78 61 6d 70 6c 65 03 63 6f
+  6d 00 00 1c 00 01