[svn] commit: r630 - in /branches/parkinglot/src/lib/dns/cpp: messagerenderer.cc messagerenderer_unittest.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Jan 29 03:14:10 UTC 2010
Author: jinmei
Date: Fri Jan 29 03:14:10 2010
New Revision: 630
Log:
fixed a crash bug in rendering the root name.
added a test case to catch this bug.
Modified:
branches/parkinglot/src/lib/dns/cpp/messagerenderer.cc
branches/parkinglot/src/lib/dns/cpp/messagerenderer_unittest.cc
Modified: branches/parkinglot/src/lib/dns/cpp/messagerenderer.cc
==============================================================================
--- branches/parkinglot/src/lib/dns/cpp/messagerenderer.cc (original)
+++ branches/parkinglot/src/lib/dns/cpp/messagerenderer.cc Fri Jan 29 03:14:10 2010
@@ -219,7 +219,8 @@
name.toWire(impl_->nbuffer_);
unsigned int i;
- std::set<NameCompressNode>::const_iterator n;
+ std::set<NameCompressNode>::const_iterator notfound = impl_->nodeset_.end();
+ std::set<NameCompressNode>::const_iterator n = notfound;
// Find the longest ancestor name in the rendered set that matches the
// given name.
@@ -231,7 +232,7 @@
n = impl_->nodeset_.find(NameCompressNode(impl_->nbuffer_, i,
impl_->nbuffer_.getLength() -
i));
- if (n != impl_->nodeset_.end()) {
+ if (n != notfound) {
break;
}
}
@@ -241,7 +242,7 @@
// Write uncompress part...
impl_->buffer_.writeData(impl_->nbuffer_.getData(),
compress ? i : impl_->nbuffer_.getLength());
- if (compress && n != impl_->nodeset_.end()) {
+ if (compress && n != notfound) {
// ...and compression pointer if available.
uint16_t pointer = (*n).pos_;
pointer |= Name::COMPRESS_POINTER_MARK16;
Modified: branches/parkinglot/src/lib/dns/cpp/messagerenderer_unittest.cc
==============================================================================
--- branches/parkinglot/src/lib/dns/cpp/messagerenderer_unittest.cc (original)
+++ branches/parkinglot/src/lib/dns/cpp/messagerenderer_unittest.cc Fri Jan 29 03:14:10 2010
@@ -113,4 +113,24 @@
EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, buffer.getData(),
buffer.getLength(), &data[0], data.size());
}
+
+TEST_F(MessageRendererTest, writeRootName)
+{
+ // root name is special: it never causes compression or can (reasonably)
+ // be a compression pointer. So it makes sense to check this case
+ // explicitly.
+ Name example_name = Name("www.example.com");
+
+ OutputBuffer expected(0);
+ expected.writeUint8(0); // root name
+ example_name.toWire(expected);
+
+ renderer.writeName(Name("."));
+ renderer.writeName(example_name);
+ EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData,
+ static_cast<const uint8_t*>(buffer.getData()),
+ buffer.getLength(),
+ static_cast<const uint8_t*>(expected.getData()),
+ expected.getLength());
}
+}
More information about the bind10-changes
mailing list