Commit 518690ed authored by JINMEI Tatuya's avatar JINMEI Tatuya

reject class mismatch cases


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1400 e5f2f494-b856-4b98-b285-d166d9295462
parent fcd4ba60
......@@ -113,7 +113,7 @@ const char* const q_prevnsec3_str = "SELECT hash FROM nsec3 "
// ID if found. This will always be >= 0 if found.
//
int
Sqlite3DataSrc::hasExactZone(const char* name) const {
Sqlite3DataSrc::hasExactZone(const char* const name) const {
int rc;
sqlite3_reset(dbparameters->q_zone_);
......@@ -482,6 +482,9 @@ Sqlite3DataSrc::findRRset(const Name& qname,
uint32_t& flags,
const Name* zonename) const
{
if (qclass != getClass()) {
return (ERROR);
}
findRecords(qname, qtype, target, zonename, NORMAL, flags);
return (SUCCESS);
}
......@@ -494,6 +497,9 @@ Sqlite3DataSrc::findExactRRset(const Name& qname,
uint32_t& flags,
const Name* zonename) const
{
if (qclass != getClass()) {
return (ERROR);
}
findRecords(qname, qtype, target, zonename, NORMAL, flags);
// Ignore referrals in this case
......@@ -515,6 +521,9 @@ Sqlite3DataSrc::findAddrs(const Name& qname,
uint32_t& flags,
const Name* zonename) const
{
if (qclass != getClass()) {
return (ERROR);
}
findRecords(qname, RRType::ANY(), target, zonename, ADDRESS, flags);
return (SUCCESS);
}
......@@ -526,6 +535,9 @@ Sqlite3DataSrc::findReferral(const Name& qname,
uint32_t& flags,
const Name* zonename) const
{
if (qclass != getClass()) {
return (ERROR);
}
findRecords(qname, RRType::ANY(), target, zonename, DELEGATION, flags);
return (SUCCESS);
}
......
......@@ -431,6 +431,13 @@ TEST_F(Sqlite3DataSourceTest, findClosestEnclosureNoMatch) {
EXPECT_EQ(NULL, name_match.bestDataSrc());
}
TEST_F(Sqlite3DataSourceTest, findClosestClassMismatch) {
NameMatch name_match(www_name);
data_source.findClosestEnclosure(name_match, RRClass::CH());
EXPECT_EQ(NULL, name_match.closestName());
EXPECT_EQ(NULL, name_match.bestDataSrc());
}
TEST_F(Sqlite3DataSourceTest, findRRsetNormal) {
// Without specifying the zone name, and then with the zone name
checkFind(NORMAL, data_source, www_name, NULL, rrclass, rrtype,
......@@ -447,6 +454,12 @@ TEST_F(Sqlite3DataSourceTest, findRRsetNormal) {
EXPECT_TRUE(result_sets.begin() == result_sets.end()); // should be empty
}
TEST_F(Sqlite3DataSourceTest, findRRsetClassMismatch) {
EXPECT_EQ(DataSrc::ERROR,
data_source.findRRset(www_name, RRClass::CH(), rrtype,
result_sets, find_flags, NULL));
}
TEST_F(Sqlite3DataSourceTest, findRRsetNormalANY) {
types.push_back(RRType::A());
types.push_back(RRType::NSEC());
......@@ -729,6 +742,13 @@ TEST_F(Sqlite3DataSourceTest, findExactRRset) {
rrttl, 0, common_a_data, &common_sig_data);
}
TEST_F(Sqlite3DataSourceTest, findExactRRsetClassMismatch) {
// Normal case. No different than findRRset.
EXPECT_EQ(DataSrc::ERROR,
data_source.findExactRRset(www_name, RRClass::CH(), rrtype,
result_sets, find_flags, NULL));
}
TEST_F(Sqlite3DataSourceTest, findRRsetNSEC3) {
// Simple NSEC3 tests (more should be added)
string hashstr("1BB7SO0452U1QHL98UISNDD9218GELR5");
......@@ -787,6 +807,12 @@ TEST_F(Sqlite3DataSourceTest, findReferralRRset) {
}
#endif
TEST_F(Sqlite3DataSourceTest, findReferralRRsetClassMismatch) {
EXPECT_EQ(DataSrc::ERROR,
data_source.findReferral(www_name, RRClass::CH(), result_sets,
find_flags, NULL));
}
TEST_F(Sqlite3DataSourceTest, findReferralRRsetDNAME) {
// same as above. the DNAME case.
const Name qname("dname.example.com");
......@@ -835,4 +861,10 @@ TEST_F(Sqlite3DataSourceTest, findAddressRRset) {
EXPECT_TRUE(result_sets.begin() == result_sets.end());
}
TEST_F(Sqlite3DataSourceTest, findAddressRRsetClassMismatch) {
EXPECT_EQ(DataSrc::ERROR, data_source.findAddrs(www_name, RRClass::CH(),
result_sets, find_flags,
NULL));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment