BIND 10 trac2420, updated. bb38dbf06510c2a9dfa60b68e56836404d62f694 [2420] re-create updater in clearZoneData() to avoid referencing invalid data
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Nov 27 22:06:34 UTC 2012
The branch, trac2420 has been updated
via bb38dbf06510c2a9dfa60b68e56836404d62f694 (commit)
from c42c6b938afa4e77d8b0545f1b2dbd335c9d3890 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit bb38dbf06510c2a9dfa60b68e56836404d62f694
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Tue Nov 27 14:05:43 2012 -0800
[2420] re-create updater in clearZoneData() to avoid referencing invalid data
-----------------------------------------------------------------------
Summary of changes:
.../tests/memory/zone_data_updater_unittest.cc | 86 ++++++++++----------
1 file changed, 45 insertions(+), 41 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/tests/memory/zone_data_updater_unittest.cc b/src/lib/datasrc/tests/memory/zone_data_updater_unittest.cc
index 22ee9d9..3f72fa9 100644
--- a/src/lib/datasrc/tests/memory/zone_data_updater_unittest.cc
+++ b/src/lib/datasrc/tests/memory/zone_data_updater_unittest.cc
@@ -28,6 +28,8 @@
#include <gtest/gtest.h>
+#include <boost/scoped_ptr.hpp>
+
#include <cassert>
using isc::testutils::textToRRset;
@@ -41,7 +43,7 @@ protected:
ZoneDataUpdaterTest() :
zname_("example.org"), zclass_(RRClass::IN()),
zone_data_(ZoneData::create(mem_sgmt_, zname_)),
- updater_(mem_sgmt_, zclass_, zname_, *zone_data_)
+ updater_(new ZoneDataUpdater(mem_sgmt_, zclass_, zname_, *zone_data_))
{}
~ZoneDataUpdaterTest() {
// Make sure zone data is destroyed even if a test results in exception
@@ -53,6 +55,8 @@ protected:
assert(zone_data_ != NULL);
ZoneData::destroy(mem_sgmt_, zone_data_, zclass_);
zone_data_ = ZoneData::create(mem_sgmt_, zname_);
+ updater_.reset(new ZoneDataUpdater(mem_sgmt_, zclass_, zname_,
+ *zone_data_));
}
void TearDown() {
@@ -66,12 +70,12 @@ protected:
const RRClass zclass_;
test::MemorySegmentTest mem_sgmt_;
ZoneData* zone_data_;
- ZoneDataUpdater updater_;
+ boost::scoped_ptr<ZoneDataUpdater> updater_;
};
TEST_F(ZoneDataUpdaterTest, bothNull) {
// At least either covered RRset or RRSIG must be non NULL.
- EXPECT_THROW(updater_.add(ConstRRsetPtr(), ConstRRsetPtr()),
+ EXPECT_THROW(updater_->add(ConstRRsetPtr(), ConstRRsetPtr()),
ZoneDataUpdater::NullRRset);
}
@@ -88,9 +92,9 @@ getNode(isc::util::MemorySegment& mem_sgmt, const Name& name,
TEST_F(ZoneDataUpdaterTest, rrsigOnly) {
// RRSIG that doesn't have covered RRset can be added. The resulting
// rdataset won't have "normal" RDATA but sig RDATA.
- updater_.add(ConstRRsetPtr(), textToRRset(
- "www.example.org. 3600 IN RRSIG A 5 3 3600 20150420235959"
- " 20051021000000 1 example.org. FAKE"));
+ updater_->add(ConstRRsetPtr(), textToRRset(
+ "www.example.org. 3600 IN RRSIG A 5 3 3600 "
+ "20150420235959 20051021000000 1 example.org. FAKE"));
ZoneNode* node = getNode(mem_sgmt_, Name("www.example.org"), zone_data_);
const RdataSet* rdset = node->getData();
ASSERT_NE(static_cast<RdataSet*>(NULL), rdset);
@@ -102,44 +106,44 @@ TEST_F(ZoneDataUpdaterTest, rrsigOnly) {
// The RRSIG covering A prohibits an actual A RRset from being added.
// This should be loosened in future version, but we check the current
// behavior.
- EXPECT_THROW(updater_.add(
+ EXPECT_THROW(updater_->add(
textToRRset("www.example.org. 3600 IN A 192.0.2.1"),
ConstRRsetPtr()), ZoneDataUpdater::AddError);
// The special "wildcarding" node mark should be added for the RRSIG-only
// case, too.
- updater_.add(ConstRRsetPtr(), textToRRset(
- "*.wild.example.org. 3600 IN RRSIG A 5 3 3600 "
- "20150420235959 20051021000000 1 example.org. FAKE"));
+ updater_->add(ConstRRsetPtr(), textToRRset(
+ "*.wild.example.org. 3600 IN RRSIG A 5 3 3600 "
+ "20150420235959 20051021000000 1 example.org. FAKE"));
node = getNode(mem_sgmt_, Name("wild.example.org"), zone_data_);
EXPECT_TRUE(node->getFlag(ZoneData::WILDCARD_NODE));
// Simply adding RRSIG covering (delegating NS) shouldn't enable callback
// in search.
- updater_.add(ConstRRsetPtr(), textToRRset(
- "child.example.org. 3600 IN RRSIG NS 5 3 3600 "
- "20150420235959 20051021000000 1 example.org. FAKE"));
+ updater_->add(ConstRRsetPtr(), textToRRset(
+ "child.example.org. 3600 IN RRSIG NS 5 3 3600 "
+ "20150420235959 20051021000000 1 example.org. FAKE"));
node = getNode(mem_sgmt_, Name("child.example.org"), zone_data_);
EXPECT_FALSE(node->getFlag(ZoneNode::FLAG_CALLBACK));
// Same for DNAME
- updater_.add(ConstRRsetPtr(), textToRRset(
- "dname.example.org. 3600 IN RRSIG DNAME 5 3 3600 "
- "20150420235959 20051021000000 1 example.org. FAKE"));
+ updater_->add(ConstRRsetPtr(), textToRRset(
+ "dname.example.org. 3600 IN RRSIG DNAME 5 3 3600 "
+ "20150420235959 20051021000000 1 example.org. FAKE"));
node = getNode(mem_sgmt_, Name("dname.example.org"), zone_data_);
EXPECT_FALSE(node->getFlag(ZoneNode::FLAG_CALLBACK));
// Likewise, RRSIG for NSEC3PARAM alone shouldn't make the zone
// "NSEC3-signed".
- updater_.add(ConstRRsetPtr(), textToRRset(
- "example.org. 3600 IN RRSIG NSEC3PARAM 5 3 3600 "
- "20150420235959 20051021000000 1 example.org. FAKE"));
+ updater_->add(ConstRRsetPtr(), textToRRset(
+ "example.org. 3600 IN RRSIG NSEC3PARAM 5 3 3600 "
+ "20150420235959 20051021000000 1 example.org. FAKE"));
EXPECT_FALSE(zone_data_->isNSEC3Signed());
// And same for (RRSIG for) NSEC and "is signed".
- updater_.add(ConstRRsetPtr(), textToRRset(
- "example.org. 3600 IN RRSIG NSEC 5 3 3600 "
- "20150420235959 20051021000000 1 example.org. FAKE"));
+ updater_->add(ConstRRsetPtr(), textToRRset(
+ "example.org. 3600 IN RRSIG NSEC 5 3 3600 "
+ "20150420235959 20051021000000 1 example.org. FAKE"));
EXPECT_FALSE(zone_data_->isSigned());
}
@@ -168,35 +172,35 @@ TEST_F(ZoneDataUpdaterTest, rrsigForNSEC3Only) {
// but that doesn't matter for this test.
// Add NSEC3PARAM, then RRSIG-only, which is okay.
- updater_.add(textToRRset(
- "example.org. 3600 IN NSEC3PARAM 1 0 12 AABBCCDD"),
- textToRRset(
- "example.org. 3600 IN RRSIG NSEC3PARAM 5 3 3600 "
- "20150420235959 20051021000000 1 example.org. FAKE"));
+ updater_->add(textToRRset(
+ "example.org. 3600 IN NSEC3PARAM 1 0 12 AABBCCDD"),
+ textToRRset(
+ "example.org. 3600 IN RRSIG NSEC3PARAM 5 3 3600 "
+ "20150420235959 20051021000000 1 example.org. FAKE"));
EXPECT_TRUE(zone_data_->isNSEC3Signed());
- updater_.add(ConstRRsetPtr(),
- textToRRset(
- "09GM.example.org. 3600 IN RRSIG NSEC3 5 3 3600 "
- "20150420235959 20051021000000 1 example.org. FAKE"));
+ updater_->add(ConstRRsetPtr(),
+ textToRRset(
+ "09GM.example.org. 3600 IN RRSIG NSEC3 5 3 3600 "
+ "20150420235959 20051021000000 1 example.org. FAKE"));
checkNSEC3Rdata(mem_sgmt_, Name("09GM.example.org"), zone_data_);
// Clear the current content of zone, then add NSEC3
clearZoneData();
- updater_.add(textToRRset(
- "AABB.example.org. 3600 IN NSEC3 1 0 10 AA 00000000 A"),
- textToRRset(
- "AABB.example.org. 3600 IN RRSIG NSEC3 5 3 3600 "
- "20150420235959 20051021000000 1 example.org. FAKE"));
- updater_.add(ConstRRsetPtr(),
- textToRRset(
- "09GM.example.org. 3600 IN RRSIG NSEC3 5 3 3600 "
- "20150420235959 20051021000000 1 example.org. FAKE"));
+ updater_->add(textToRRset(
+ "AABB.example.org. 3600 IN NSEC3 1 0 10 AA 00000000 A"),
+ textToRRset(
+ "AABB.example.org. 3600 IN RRSIG NSEC3 5 3 3600 "
+ "20150420235959 20051021000000 1 example.org. FAKE"));
+ updater_->add(ConstRRsetPtr(),
+ textToRRset(
+ "09GM.example.org. 3600 IN RRSIG NSEC3 5 3 3600 "
+ "20150420235959 20051021000000 1 example.org. FAKE"));
checkNSEC3Rdata(mem_sgmt_, Name("09GM.example.org"), zone_data_);
// If we add only RRSIG without any NSEC3 related data beforehand,
// it will be rejected; it's a limitation of the current implementation.
clearZoneData();
- EXPECT_THROW(updater_.add(
+ EXPECT_THROW(updater_->add(
ConstRRsetPtr(),
textToRRset(
"09GM.example.org. 3600 IN RRSIG NSEC3 5 3 3600 "
More information about the bind10-changes
mailing list