summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJINMEI Tatuya <jinmei@isc.org>2012-05-26 01:27:31 +0200
committerJINMEI Tatuya <jinmei@isc.org>2012-05-31 01:34:01 +0200
commit2f88c7ad45869921177bf4dcc477dbdd87c8cda6 (patch)
tree8ee383bb50bee94e71080774ab8d52ba1067247d
parent[master] Merge branch 'trac1458' with fixing conflicts. (diff)
downloadkea-2f88c7ad45869921177bf4dcc477dbdd87c8cda6.tar.xz
kea-2f88c7ad45869921177bf4dcc477dbdd87c8cda6.zip
[2013] (related bug fix) make Message::clearSection clear questions correctly.
this fix is necessary for ddns to make responses correctly.
-rw-r--r--src/lib/dns/message.cc6
-rw-r--r--src/lib/dns/python/tests/message_python_test.py1
-rw-r--r--src/lib/dns/tests/message_unittest.cc2
3 files changed, 8 insertions, 1 deletions
diff --git a/src/lib/dns/message.cc b/src/lib/dns/message.cc
index a9be8be75e..0a1625a206 100644
--- a/src/lib/dns/message.cc
+++ b/src/lib/dns/message.cc
@@ -573,7 +573,11 @@ Message::clearSection(const Section section) {
if (section >= MessageImpl::NUM_SECTIONS) {
isc_throw(OutOfRange, "Invalid message section: " << section);
}
- impl_->rrsets_[section].clear();
+ if (section == Message::SECTION_QUESTION) {
+ impl_->questions_.clear();
+ } else {
+ impl_->rrsets_[section].clear();
+ }
impl_->counts_[section] = 0;
}
diff --git a/src/lib/dns/python/tests/message_python_test.py b/src/lib/dns/python/tests/message_python_test.py
index 1ec0e99c9d..818ddd3f32 100644
--- a/src/lib/dns/python/tests/message_python_test.py
+++ b/src/lib/dns/python/tests/message_python_test.py
@@ -295,6 +295,7 @@ class MessageTest(unittest.TestCase):
self.assertEqual(1, self.r.get_rr_count(Message.SECTION_QUESTION))
self.r.clear_section(Message.SECTION_QUESTION)
self.assertEqual(0, self.r.get_rr_count(Message.SECTION_QUESTION))
+ self.assertEqual(0, len(self.r.get_question()))
def test_clear_section(self):
for section in [Message.SECTION_ANSWER, Message.SECTION_AUTHORITY,
diff --git a/src/lib/dns/tests/message_unittest.cc b/src/lib/dns/tests/message_unittest.cc
index c5dd3eda33..f30a2acf12 100644
--- a/src/lib/dns/tests/message_unittest.cc
+++ b/src/lib/dns/tests/message_unittest.cc
@@ -406,6 +406,8 @@ TEST_F(MessageTest, clearQuestionSection) {
message_render.clearSection(Message::SECTION_QUESTION);
EXPECT_EQ(0, message_render.getRRCount(Message::SECTION_QUESTION));
+ EXPECT_TRUE(message_render.beginQuestion() ==
+ message_render.endQuestion());
}