Parcourir la source

[2108] Check that loading a zone containing NSEC3 names with invalid number of labels throws

Mukund Sivaraman il y a 12 ans
Parent
commit
41eff487ae

+ 18 - 0
src/lib/datasrc/memory/tests/memory_client_unittest.cc

@@ -317,6 +317,24 @@ TEST_F(MemoryClientTest, loadWildcardNSEC3Throws) {
     // Teardown checks for memory segment leaks
 }
 
+TEST_F(MemoryClientTest, loadNSEC3WithFewerLabelsThrows) {
+    // NSEC3 names with labels != (origin_labels + 1) should throw
+    EXPECT_THROW(client_->load(Name("example.org"),
+                               TEST_DATA_DIR
+                               "/example.org-nsec3-fewer-labels.zone"),
+                 InMemoryClient::AddError);
+    // Teardown checks for memory segment leaks
+}
+
+TEST_F(MemoryClientTest, loadNSEC3WithMoreLabelsThrows) {
+    // NSEC3 names with labels != (origin_labels + 1) should throw
+    EXPECT_THROW(client_->load(Name("example.org"),
+                               TEST_DATA_DIR
+                               "/example.org-nsec3-more-labels.zone"),
+                 InMemoryClient::AddError);
+    // Teardown checks for memory segment leaks
+}
+
 TEST_F(MemoryClientTest, loadRRSIGFollowsNothing) {
     EXPECT_THROW(client_->load(Name("example.org"),
                                TEST_DATA_DIR

+ 2 - 0
src/lib/datasrc/memory/tests/testdata/Makefile.am

@@ -21,3 +21,5 @@ EXTRA_DIST += example.org-out-of-zone.zone
 EXTRA_DIST += example.org-wildcard-ns.zone
 EXTRA_DIST += example.org-wildcard-dname.zone
 EXTRA_DIST += example.org-wildcard-nsec3.zone
+EXTRA_DIST += example.org-nsec3-fewer-labels.zone
+EXTRA_DIST += example.org-nsec3-more-labels.zone

+ 3 - 0
src/lib/datasrc/memory/tests/testdata/example.org-nsec3-fewer-labels.zone

@@ -0,0 +1,3 @@
+;; NSEC3 names with labels != (origin_labels + 1)
+example.org.				      86400 IN SOA	ns.example.org. ns.example.org. 2012091001 7200 3600 2592000 1200
+example.org. 1200 IN NSEC3	1 0 10 AABBCCDD RKOF8QMFRB5F2V9EJHFBVB2JPVSA0DJD A RRSIG

+ 3 - 0
src/lib/datasrc/memory/tests/testdata/example.org-nsec3-more-labels.zone

@@ -0,0 +1,3 @@
+;; NSEC3 names with labels != (origin_labels + 1)
+example.org.				      86400 IN SOA	ns.example.org. ns.example.org. 2012091002 7200 3600 2592000 1200
+a.b.example.org. 1200 IN NSEC3	1 0 10 AABBCCDD RKOF8QMFRB5F2V9EJHFBVB2JPVSA0DJD A RRSIG