[svn] commit: r2314 - in /branches/trac192/src/lib/datasrc: data_source.cc tests/datasrc_unittest.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Jun 28 20:28:25 UTC 2010
Author: each
Date: Mon Jun 28 20:28:25 2010
New Revision: 2314
Log:
Check for class and name mismatches in DataSrcMatch::update().
Modified:
branches/trac192/src/lib/datasrc/data_source.cc
branches/trac192/src/lib/datasrc/tests/datasrc_unittest.cc
Modified: branches/trac192/src/lib/datasrc/data_source.cc
==============================================================================
--- branches/trac192/src/lib/datasrc/data_source.cc (original)
+++ branches/trac192/src/lib/datasrc/data_source.cc Mon Jun 28 20:28:25 2010
@@ -1164,7 +1164,21 @@
void
DataSrcMatch::update(const DataSrc& new_source, const Name& container) {
+ if (getClass() != new_source.getClass() && getClass() != RRClass::ANY() &&
+ new_source.getClass() != RRClass::ANY())
+ {
+ return;
+ }
+
if (closest_name_ == NULL) {
+ const NameComparisonResult::NameRelation cmp =
+ getName().compare(container).getRelation();
+ if (cmp != NameComparisonResult::EQUAL &&
+ cmp != NameComparisonResult::SUBDOMAIN)
+ {
+ return;
+ }
+
closest_name_ = new Name(container);
best_source_ = &new_source;
return;
Modified: branches/trac192/src/lib/datasrc/tests/datasrc_unittest.cc
==============================================================================
--- branches/trac192/src/lib/datasrc/tests/datasrc_unittest.cc (original)
+++ branches/trac192/src/lib/datasrc/tests/datasrc_unittest.cc Mon Jun 28 20:28:25 2010
@@ -902,17 +902,16 @@
TEST_F(DataSrcMatchTest, updateWithWrongClass) {
DataSrcMatch match(Name("www.example.com"), RRClass::CH());
+
+ EXPECT_EQ(RRClass::IN(), datasrc2.getClass());
match.update(datasrc2, Name("com"));
- EXPECT_EQ(Name("com"), *match.getEnclosingZone());
- EXPECT_EQ(&datasrc2, match.getDataSource());
-
- // datasrc1 gives a better enclosing name, but RR class doesn't match.
- // hmm...what should we do? the current implementation simply ignores
- // the mismatch of the class, but it doesn't seem to be correct.
+ EXPECT_EQ(NULL, match.getEnclosingZone());
+ EXPECT_EQ(NULL, match.getDataSource());
+
EXPECT_EQ(RRClass::IN(), datasrc1.getClass());
match.update(datasrc1, Name("example.com"));
- EXPECT_EQ(Name("example.com"), *match.getEnclosingZone());
- EXPECT_EQ(&datasrc1, match.getDataSource());
+ EXPECT_EQ(NULL, match.getEnclosingZone());
+ EXPECT_EQ(NULL, match.getDataSource());
}
TEST_F(DataSrcMatchTest, updateAgainstAnyClass) {
@@ -921,9 +920,7 @@
EXPECT_EQ(Name("com"), *match.getEnclosingZone());
EXPECT_EQ(&datasrc2, match.getDataSource());
- // see the previous test. in this case the given class for search is
- // ANY, so update should be okay. but the fact is that the implementation
- // simply ignores the RR class.
+ // the given class for search is ANY, so update should be okay.
EXPECT_EQ(RRClass::IN(), datasrc1.getClass());
match.update(datasrc1, Name("example.com"));
EXPECT_EQ(Name("example.com"), *match.getEnclosingZone());
@@ -944,7 +941,7 @@
}
// This test currently fails.
-TEST_F(DataSrcMatchTest, DISABLED_initialUpdateWithNoMatch) {
+TEST_F(DataSrcMatchTest, initialUpdateWithNoMatch) {
DataSrcMatch match(Name("www.example.com"), RRClass::IN());
// An initial attempt of update with a name that doesn't match.
More information about the bind10-changes
mailing list