summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/dns/rdata/generic/caa_257.cc7
-rw-r--r--src/lib/dns/tests/rdata_caa_unittest.cc6
2 files changed, 11 insertions, 2 deletions
diff --git a/src/lib/dns/rdata/generic/caa_257.cc b/src/lib/dns/rdata/generic/caa_257.cc
index a031ab1ede..9e6fa9bab5 100644
--- a/src/lib/dns/rdata/generic/caa_257.cc
+++ b/src/lib/dns/rdata/generic/caa_257.cc
@@ -195,9 +195,12 @@ CAA::CAA(uint8_t flags, const std::string& tag, const std::string& value) :
"CAA tag field is too large: " << tag.size());
}
+ MasterToken::StringRegion region;
+ region.beg = &value[0]; // note std ensures this works even if str is empty
+ region.len = value.size();
+
detail::CharStringData value_vec;
- value_vec.reserve(value.size());
- value_vec.insert(value_vec.end(), value.begin(), value.end());
+ detail::stringToCharStringData(region, value_vec);
impl_ = new CAAImpl(flags, tag, value_vec);
}
diff --git a/src/lib/dns/tests/rdata_caa_unittest.cc b/src/lib/dns/tests/rdata_caa_unittest.cc
index 05d177e00f..a2a9f9ea80 100644
--- a/src/lib/dns/tests/rdata_caa_unittest.cc
+++ b/src/lib/dns/tests/rdata_caa_unittest.cc
@@ -207,6 +207,12 @@ TEST_F(Rdata_CAA_Test, createFromParams) {
const generic::CAA rdata_caa2(0, "issue", "ca.example.net");
EXPECT_EQ(0, rdata_caa2.compare(rdata_caa));
+ const generic::CAA rdata_caa4(0, "issue", "ca.e\\xample.net");
+ EXPECT_EQ(0, rdata_caa4.compare(rdata_caa));
+
+ const generic::CAA rdata_caa5(0, "issue", "ca.e\\120ample.net");
+ EXPECT_EQ(0, rdata_caa5.compare(rdata_caa));
+
// Tag is empty
EXPECT_THROW(const generic::CAA rdata_caa3(0, "", "ca.example.net"),
isc::InvalidParameter);