BIND 10 master, updated. 94df9fad7ddbe91fff09b601cfaf07fcfd346659 [master] Update ChangeLog for #2390 and #2656
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Feb 1 10:46:21 UTC 2013
The branch, master has been updated
via 94df9fad7ddbe91fff09b601cfaf07fcfd346659 (commit)
via 5a0d055137287f81e23fbeedd35236fee274596d (commit)
via 271e37c6b0befddbf9291577460868f0c67ea428 (commit)
via f59c311cfd135589af52c6f8a9afa45c03f84318 (commit)
via 10833250f2751b41b6d9e9b86be5396ec3b4e062 (commit)
via d8c50d0baef0ad3a1339b1c03bd0d37a32719d86 (commit)
via 7e110b499a751ca43a473a94eb4448bdbe78a32a (commit)
via 2db190194445d191e1d1eb75f0fc1936d0a791df (commit)
via 17a9c25450a3129fa5787a5deb70d371a602f311 (commit)
via c5efaec3f9196e4b4cabccde691f30ad9de380ba (commit)
via ae25fcc7abecb79eb3d4b9df1e0b463c27f77258 (commit)
via 58ccf7aa110fe656c52060cbc7b2cc26b4a9ae9d (commit)
via 0aafc9b4325734e8d8d16805ad459f8dde153fdb (commit)
via af2672cf1515f459dfc5db30919c407abcb8273b (commit)
via e4cd5386850b79a824320a63bfed69f03358574f (commit)
via 7ddf561d6304d62ce755344b0e28ab9b025b9f27 (commit)
from a01569277cda3f78b1171bbf79f15ecf502e81e2 (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 94df9fad7ddbe91fff09b601cfaf07fcfd346659
Author: Mukund Sivaraman <muks at isc.org>
Date: Fri Feb 1 16:09:31 2013 +0530
[master] Update ChangeLog for #2390 and #2656
commit 5a0d055137287f81e23fbeedd35236fee274596d
Merge: 271e37c a015692
Author: Mukund Sivaraman <muks at isc.org>
Date: Fri Feb 1 16:08:01 2013 +0530
Merge branch 'master' into trac2656_2
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 12 ++
src/lib/datasrc/tests/database_unittest.cc | 4 +-
.../tests/memory/rdata_serialization_unittest.cc | 2 +-
.../datasrc/tests/memory/zone_finder_unittest.cc | 2 +-
src/lib/datasrc/tests/memory_datasrc_unittest.cc | 2 +-
src/lib/dns/gen-rdatacode.py.in | 3 +
src/lib/dns/rdata/generic/cname_5.cc | 59 ++++++++-
src/lib/dns/rdata/generic/dname_39.cc | 59 ++++++++-
src/lib/dns/rdata/generic/mx_15.cc | 1 +
src/lib/dns/rdata/generic/ns_2.cc | 1 +
src/lib/dns/rdata/generic/ptr_12.cc | 3 +
src/lib/dns/rdata/in_1/srv_33.cc | 129 ++++++++++++++------
src/lib/dns/tests/rdata_cname_unittest.cc | 29 +++--
src/lib/dns/tests/rdata_dname_unittest.cc | 29 +++--
src/lib/dns/tests/rdata_srv_unittest.cc | 23 +++-
src/lib/dns/tests/zone_checker_unittest.cc | 8 +-
src/lib/python/isc/testutils/rrset_utils.py | 2 +-
.../resolve/tests/response_classifier_unittest.cc | 4 +-
18 files changed, 306 insertions(+), 66 deletions(-)
-----------------------------------------------------------------------
diff --git a/ChangeLog b/ChangeLog
index 1302c3b..1b31278 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+564. [func] muks
+ libdns++: the CNAME, DNAME, MX, NS, PTR and SRV Rdata classes now
+ use the generic lexer in constructors from text. This means that
+ the name fields in such RRs in a zone file can now be non-absolute
+ (the origin name in that context will be used), e.g., when loaded
+ by b10-loadzone. One additional change to the libdns++ API is that
+ the existing string constructors for these Rdata classes also use
+ the generic lexer, and they now expect an absolute name (with the
+ trailing '.') in the name fields.
+ (Trac #2390, git a01569277cda3f78b1171bbf79f15ecf502e81e2)
+ (Trac #2656, git 5a0d055137287f81e23fbeedd35236fee274596d)
+
563. [build] jinmei
Added --disable-rpath configure option to avoid embedding library
paths to binaries. Patch from Adam Tkac.
diff --git a/src/lib/datasrc/tests/database_unittest.cc b/src/lib/datasrc/tests/database_unittest.cc
index cb8ed41..58af193 100644
--- a/src/lib/datasrc/tests/database_unittest.cc
+++ b/src/lib/datasrc/tests/database_unittest.cc
@@ -3649,7 +3649,7 @@ TYPED_TEST(DatabaseClientTest, deleteRRset) {
RRType::CNAME(), this->rrttl_));
this->rrset_->addRdata(rdata::createRdata(this->rrset_->getType(),
this->rrset_->getClass(),
- "www.example.org"));
+ "www.example.org."));
this->updater_->deleteRRset(*this->rrset_);
// The this->updater_ finder should immediately see the deleted results.
@@ -3701,7 +3701,7 @@ TYPED_TEST(DatabaseClientTest, deleteRRsetToNXDOMAIN) {
RRType::CNAME(), this->rrttl_));
this->rrset_->addRdata(rdata::createRdata(this->rrset_->getType(),
this->rrset_->getClass(),
- "www.example.org"));
+ "www.example.org."));
this->updater_ = this->client_->getUpdater(this->zname_, false);
this->updater_->deleteRRset(*this->rrset_);
diff --git a/src/lib/datasrc/tests/memory/rdata_serialization_unittest.cc b/src/lib/datasrc/tests/memory/rdata_serialization_unittest.cc
index 1e70900..b36b294 100644
--- a/src/lib/datasrc/tests/memory/rdata_serialization_unittest.cc
+++ b/src/lib/datasrc/tests/memory/rdata_serialization_unittest.cc
@@ -773,7 +773,7 @@ TEST_F(RdataSerializationTest, badAddRdata) {
// Same as the previous one, opposite inconsistency.
const ConstRdataPtr dname_rdata =
- createRdata(RRType::DNAME(), RRClass::IN(), "dname.example");
+ createRdata(RRType::DNAME(), RRClass::IN(), "dname.example.");
encoder_.start(RRClass::IN(), RRType::NS());
EXPECT_THROW(encoder_.addRdata(*dname_rdata), isc::BadValue);
diff --git a/src/lib/datasrc/tests/memory/zone_finder_unittest.cc b/src/lib/datasrc/tests/memory/zone_finder_unittest.cc
index 2ce2c67..e59013e 100644
--- a/src/lib/datasrc/tests/memory/zone_finder_unittest.cc
+++ b/src/lib/datasrc/tests/memory/zone_finder_unittest.cc
@@ -112,7 +112,7 @@ protected:
// This one will place rr_ns_a_ at a zone cut, making it a glue:
{"ns.example.org. 300 IN NS 192.0.2.2.", &rr_ns_ns_},
{"ns.example.org. 300 IN AAAA 2001:db8::2", &rr_ns_aaaa_},
- {"cname.example.org. 300 IN CNAME canonical.example.org",
+ {"cname.example.org. 300 IN CNAME canonical.example.org.",
&rr_cname_},
{"cname.example.org. 300 IN A 192.0.2.3", &rr_cname_a_},
{"dname.example.org. 300 IN DNAME target.example.org.",
diff --git a/src/lib/datasrc/tests/memory_datasrc_unittest.cc b/src/lib/datasrc/tests/memory_datasrc_unittest.cc
index 81eb3ca..f7a478b 100644
--- a/src/lib/datasrc/tests/memory_datasrc_unittest.cc
+++ b/src/lib/datasrc/tests/memory_datasrc_unittest.cc
@@ -347,7 +347,7 @@ public:
{"example.org. 300 IN A 192.0.2.1", &rr_a_},
{"ns.example.org. 300 IN A 192.0.2.2", &rr_ns_a_},
{"ns.example.org. 300 IN AAAA 2001:db8::2", &rr_ns_aaaa_},
- {"cname.example.org. 300 IN CNAME canonical.example.org",
+ {"cname.example.org. 300 IN CNAME canonical.example.org.",
&rr_cname_},
{"cname.example.org. 300 IN A 192.0.2.3", &rr_cname_a_},
{"dname.example.org. 300 IN DNAME target.example.org.",
diff --git a/src/lib/dns/gen-rdatacode.py.in b/src/lib/dns/gen-rdatacode.py.in
index b653126..ab2fa2e 100755
--- a/src/lib/dns/gen-rdatacode.py.in
+++ b/src/lib/dns/gen-rdatacode.py.in
@@ -33,6 +33,8 @@ import sys
# Example:
# new_rdata_factory_users = [('a', 'in'), ('a', 'ch'), ('soa', 'generic')]
new_rdata_factory_users = [('aaaa', 'in'),
+ ('cname', 'generic'),
+ ('dname', 'generic'),
('hinfo', 'generic'),
('naptr', 'generic'),
('mx', 'generic'),
@@ -40,6 +42,7 @@ new_rdata_factory_users = [('aaaa', 'in'),
('ptr', 'generic'),
('soa', 'generic'),
('spf', 'generic'),
+ ('srv', 'in'),
('txt', 'generic')
]
diff --git a/src/lib/dns/rdata/generic/cname_5.cc b/src/lib/dns/rdata/generic/cname_5.cc
index 5bb0aea..e87eeec 100644
--- a/src/lib/dns/rdata/generic/cname_5.cc
+++ b/src/lib/dns/rdata/generic/cname_5.cc
@@ -22,15 +22,49 @@
#include <dns/rdata.h>
#include <dns/rdataclass.h>
+#include <dns/rdata/generic/detail/lexer_util.h>
+
using namespace std;
using namespace isc::util;
+using isc::dns::rdata::generic::detail::createNameFromLexer;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
+/// \brief Constructor from string.
+///
+/// The given string must represent a valid CNAME RDATA. There can be extra
+/// space characters at the beginning or end of the text (which are simply
+/// ignored), but other extra text, including a new line, will make the
+/// construction fail with an exception.
+///
+/// The CNAME must be absolute since there's no parameter that specifies
+/// the origin name; if it is not absolute, \c MissingNameOrigin
+/// exception will be thrown. These must not be represented as a quoted
+/// string.
+///
+/// \throw Others Exception from the Name and RRTTL constructors.
+/// \throw InvalidRdataText Other general syntax errors.
CNAME::CNAME(const std::string& namestr) :
- cname_(namestr)
-{}
+ // Fill in dummy name and replace it soon below.
+ cname_(Name::ROOT_NAME())
+{
+ try {
+ std::istringstream ss(namestr);
+ MasterLexer lexer;
+ lexer.pushSource(ss);
+
+ cname_ = createNameFromLexer(lexer, NULL);
+
+ if (lexer.getNextToken().getType() != MasterToken::END_OF_FILE) {
+ isc_throw(InvalidRdataText, "extra input text for CNAME: "
+ << namestr);
+ }
+ } catch (const MasterLexer::LexerError& ex) {
+ isc_throw(InvalidRdataText, "Failed to construct CNAME from '" <<
+ namestr << "': " << ex.what());
+ }
+}
CNAME::CNAME(InputBuffer& buffer, size_t) :
Rdata(), cname_(buffer)
@@ -39,6 +73,27 @@ CNAME::CNAME(InputBuffer& buffer, size_t) :
// check consistency.
}
+/// \brief Constructor with a context of MasterLexer.
+///
+/// The \c lexer should point to the beginning of valid textual
+/// representation of a CNAME RDATA. The CNAME field can be
+/// non-absolute if \c origin is non-NULL, in which case \c origin is
+/// used to make it absolute. It must not be represented as a quoted
+/// string.
+///
+/// \throw MasterLexer::LexerError General parsing error such as missing field.
+/// \throw Other Exceptions from the Name and RRTTL constructors if
+/// construction of textual fields as these objects fail.
+///
+/// \param lexer A \c MasterLexer object parsing a master file for the
+/// RDATA to be created
+/// \param origin If non NULL, specifies the origin of CNAME when it
+/// is non-absolute.
+CNAME::CNAME(MasterLexer& lexer, const Name* origin,
+ MasterLoader::Options, MasterLoaderCallbacks&) :
+ cname_(createNameFromLexer(lexer, origin))
+{}
+
CNAME::CNAME(const CNAME& other) :
Rdata(), cname_(other.cname_)
{}
diff --git a/src/lib/dns/rdata/generic/dname_39.cc b/src/lib/dns/rdata/generic/dname_39.cc
index a22fcc3..d1d349e 100644
--- a/src/lib/dns/rdata/generic/dname_39.cc
+++ b/src/lib/dns/rdata/generic/dname_39.cc
@@ -22,15 +22,49 @@
#include <dns/rdata.h>
#include <dns/rdataclass.h>
+#include <dns/rdata/generic/detail/lexer_util.h>
+
using namespace std;
using namespace isc::util;
+using isc::dns::rdata::generic::detail::createNameFromLexer;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
+/// \brief Constructor from string.
+///
+/// The given string must represent a valid DNAME RDATA. There can be extra
+/// space characters at the beginning or end of the text (which are simply
+/// ignored), but other extra text, including a new line, will make the
+/// construction fail with an exception.
+///
+/// The TARGET must be absolute since there's no parameter that specifies
+/// the origin name; if it is not absolute, \c MissingNameOrigin
+/// exception will be thrown. These must not be represented as a quoted
+/// string.
+///
+/// \throw Others Exception from the Name and RRTTL constructors.
+/// \throw InvalidRdataText Other general syntax errors.
DNAME::DNAME(const std::string& namestr) :
- dname_(namestr)
-{}
+ // Fill in dummy name and replace it soon below.
+ dname_(Name::ROOT_NAME())
+{
+ try {
+ std::istringstream ss(namestr);
+ MasterLexer lexer;
+ lexer.pushSource(ss);
+
+ dname_ = createNameFromLexer(lexer, NULL);
+
+ if (lexer.getNextToken().getType() != MasterToken::END_OF_FILE) {
+ isc_throw(InvalidRdataText, "extra input text for DNAME: "
+ << namestr);
+ }
+ } catch (const MasterLexer::LexerError& ex) {
+ isc_throw(InvalidRdataText, "Failed to construct DNAME from '" <<
+ namestr << "': " << ex.what());
+ }
+}
DNAME::DNAME(InputBuffer& buffer, size_t) :
dname_(buffer)
@@ -39,6 +73,27 @@ DNAME::DNAME(InputBuffer& buffer, size_t) :
// check consistency.
}
+/// \brief Constructor with a context of MasterLexer.
+///
+/// The \c lexer should point to the beginning of valid textual
+/// representation of a DNAME RDATA. The TARGET field can be
+/// non-absolute if \c origin is non-NULL, in which case \c origin is
+/// used to make it absolute. It must not be represented as a quoted
+/// string.
+///
+/// \throw MasterLexer::LexerError General parsing error such as missing field.
+/// \throw Other Exceptions from the Name and RRTTL constructors if
+/// construction of textual fields as these objects fail.
+///
+/// \param lexer A \c MasterLexer object parsing a master file for the
+/// RDATA to be created
+/// \param origin If non NULL, specifies the origin of TARGET when it
+/// is non-absolute.
+DNAME::DNAME(MasterLexer& lexer, const Name* origin,
+ MasterLoader::Options, MasterLoaderCallbacks&) :
+ dname_(createNameFromLexer(lexer, origin))
+{}
+
DNAME::DNAME(const DNAME& other) :
Rdata(), dname_(other.dname_)
{}
diff --git a/src/lib/dns/rdata/generic/mx_15.cc b/src/lib/dns/rdata/generic/mx_15.cc
index f306870..12ada97 100644
--- a/src/lib/dns/rdata/generic/mx_15.cc
+++ b/src/lib/dns/rdata/generic/mx_15.cc
@@ -31,6 +31,7 @@
using namespace std;
using boost::lexical_cast;
using namespace isc::util;
+using isc::dns::rdata::generic::detail::createNameFromLexer;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/ns_2.cc b/src/lib/dns/rdata/generic/ns_2.cc
index 2f0278f..d75ab7d 100644
--- a/src/lib/dns/rdata/generic/ns_2.cc
+++ b/src/lib/dns/rdata/generic/ns_2.cc
@@ -26,6 +26,7 @@
using namespace std;
using namespace isc::util;
+using isc::dns::rdata::generic::detail::createNameFromLexer;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/ptr_12.cc b/src/lib/dns/rdata/generic/ptr_12.cc
index beec038..080faee 100644
--- a/src/lib/dns/rdata/generic/ptr_12.cc
+++ b/src/lib/dns/rdata/generic/ptr_12.cc
@@ -22,8 +22,11 @@
#include <dns/rdata.h>
#include <dns/rdataclass.h>
+#include <dns/rdata/generic/detail/lexer_util.h>
+
using namespace std;
using namespace isc::util;
+using isc::dns::rdata::generic::detail::createNameFromLexer;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
diff --git a/src/lib/dns/rdata/in_1/srv_33.cc b/src/lib/dns/rdata/in_1/srv_33.cc
index af8bbe3..ac62071 100644
--- a/src/lib/dns/rdata/in_1/srv_33.cc
+++ b/src/lib/dns/rdata/in_1/srv_33.cc
@@ -25,9 +25,12 @@
#include <dns/rdata.h>
#include <dns/rdataclass.h>
+#include <dns/rdata/generic/detail/lexer_util.h>
+
using namespace std;
using namespace isc::util;
using namespace isc::util::str;
+using isc::dns::rdata::generic::detail::createNameFromLexer;
// BEGIN_ISC_NAMESPACE
// BEGIN_RDATA_NAMESPACE
@@ -48,45 +51,57 @@ struct SRVImpl {
/// \brief Constructor from string.
///
-/// \c srv_str must be formatted as follows:
-/// \code <Priority> <Weight> <Port> <Target>
-/// \endcode
-/// where
-/// - <Priority>, <Weight>, and <Port> are an unsigned
-/// 16-bit decimal integer.
-/// - <Target> is a valid textual representation of domain name.
-///
-/// An example of valid string is:
-/// \code "1 5 1500 example.com." \endcode
-///
-/// <b>Exceptions</b>
-///
-/// If <Target> is not a valid domain name, a corresponding exception
-/// from the \c Name class will be thrown;
-/// if %any of the other bullet points above is not met, an exception of
-/// class \c InvalidRdataText will be thrown.
-/// This constructor internally involves resource allocation, and if it fails
-/// a corresponding standard exception will be thrown.
+/// The given string must represent a valid SRV RDATA. There can be extra
+/// space characters at the beginning or end of the text (which are simply
+/// ignored), but other extra text, including a new line, will make the
+/// construction fail with an exception.
+///
+/// The TARGET name must be absolute since there's no parameter that
+/// specifies the origin name; if it is not absolute, \c MissingNameOrigin
+/// exception will be thrown. It must not be represented as a quoted
+/// string.
+///
+/// See the construction that takes \c MasterLexer for other fields.
+///
+/// \throw Others Exception from the Name and RRTTL constructors.
+/// \throw InvalidRdataText Other general syntax errors.
SRV::SRV(const std::string& srv_str) :
impl_(NULL)
{
- istringstream iss(srv_str);
-
try {
- const int32_t priority = tokenToNum<int32_t, 16>(getToken(iss));
- const int32_t weight = tokenToNum<int32_t, 16>(getToken(iss));
- const int32_t port = tokenToNum<int32_t, 16>(getToken(iss));
- const Name targetname(getToken(iss));
-
- if (!iss.eof()) {
- isc_throw(InvalidRdataText, "Unexpected input for SRV RDATA: " <<
- srv_str);
+ std::istringstream ss(srv_str);
+ MasterLexer lexer;
+ lexer.pushSource(ss);
+
+ uint32_t num = lexer.getNextToken(MasterToken::NUMBER).getNumber();
+ if (num > 65535) {
+ isc_throw(InvalidRdataText, "Invalid SRV priority in: " << srv_str);
+ }
+ const uint16_t priority = static_cast<uint16_t>(num);
+
+ num = lexer.getNextToken(MasterToken::NUMBER).getNumber();
+ if (num > 65535) {
+ isc_throw(InvalidRdataText, "Invalid SRV weight in: " << srv_str);
+ }
+ const uint16_t weight = static_cast<uint16_t>(num);
+
+ num = lexer.getNextToken(MasterToken::NUMBER).getNumber();
+ if (num > 65535) {
+ isc_throw(InvalidRdataText, "Invalid SRV port in: " << srv_str);
+ }
+ const uint16_t port = static_cast<uint16_t>(num);
+
+ const Name targetname = createNameFromLexer(lexer, NULL);
+
+ if (lexer.getNextToken().getType() != MasterToken::END_OF_FILE) {
+ isc_throw(InvalidRdataText, "extra input text for SRV: "
+ << srv_str);
}
impl_ = new SRVImpl(priority, weight, port, targetname);
- } catch (const StringTokenError& ste) {
- isc_throw(InvalidRdataText, "Invalid SRV text: " <<
- ste.what() << ": " << srv_str);
+ } catch (const MasterLexer::LexerError& ex) {
+ isc_throw(InvalidRdataText, "Failed to construct SRV from '" <<
+ srv_str << "': " << ex.what());
}
}
@@ -112,14 +127,58 @@ SRV::SRV(InputBuffer& buffer, size_t rdata_len) {
isc_throw(InvalidRdataLength, "SRV too short");
}
- uint16_t priority = buffer.readUint16();
- uint16_t weight = buffer.readUint16();
- uint16_t port = buffer.readUint16();
+ const uint16_t priority = buffer.readUint16();
+ const uint16_t weight = buffer.readUint16();
+ const uint16_t port = buffer.readUint16();
const Name targetname(buffer);
impl_ = new SRVImpl(priority, weight, port, targetname);
}
+/// \brief Constructor with a context of MasterLexer.
+///
+/// The \c lexer should point to the beginning of valid textual representation
+/// of an SRV RDATA. The TARGET field can be non-absolute if \c origin
+/// is non-NULL, in which case \c origin is used to make it absolute.
+/// It must not be represented as a quoted string.
+///
+/// The PRIORITY, WEIGHT and PORT fields must each be a valid decimal
+/// representation of an unsigned 16-bit integers respectively.
+///
+/// \throw MasterLexer::LexerError General parsing error such as missing field.
+/// \throw Other Exceptions from the Name and RRTTL constructors if
+/// construction of textual fields as these objects fail.
+///
+/// \param lexer A \c MasterLexer object parsing a master file for the
+/// RDATA to be created
+/// \param origin If non NULL, specifies the origin of TARGET when it
+/// is non-absolute.
+SRV::SRV(MasterLexer& lexer, const Name* origin,
+ MasterLoader::Options, MasterLoaderCallbacks&)
+{
+ uint32_t num = lexer.getNextToken(MasterToken::NUMBER).getNumber();
+ if (num > 65535) {
+ isc_throw(InvalidRdataText, "Invalid SRV priority: " << num);
+ }
+ const uint16_t priority = static_cast<uint16_t>(num);
+
+ num = lexer.getNextToken(MasterToken::NUMBER).getNumber();
+ if (num > 65535) {
+ isc_throw(InvalidRdataText, "Invalid SRV weight: " << num);
+ }
+ const uint16_t weight = static_cast<uint16_t>(num);
+
+ num = lexer.getNextToken(MasterToken::NUMBER).getNumber();
+ if (num > 65535) {
+ isc_throw(InvalidRdataText, "Invalid SRV port: " << num);
+ }
+ const uint16_t port = static_cast<uint16_t>(num);
+
+ const Name targetname = createNameFromLexer(lexer, origin);
+
+ impl_ = new SRVImpl(priority, weight, port, targetname);
+}
+
/// \brief The copy constructor.
///
/// It internally allocates a resource, and if it fails a corresponding
diff --git a/src/lib/dns/tests/rdata_cname_unittest.cc b/src/lib/dns/tests/rdata_cname_unittest.cc
index 6451f72..c00cab7 100644
--- a/src/lib/dns/tests/rdata_cname_unittest.cc
+++ b/src/lib/dns/tests/rdata_cname_unittest.cc
@@ -36,8 +36,8 @@ class Rdata_CNAME_Test : public RdataTest {
// there's nothing to specialize
};
-const generic::CNAME rdata_cname("cn.example.com");
-const generic::CNAME rdata_cname2("cn2.example.com");
+const generic::CNAME rdata_cname("cn.example.com.");
+const generic::CNAME rdata_cname2("cn2.example.com.");
const uint8_t wiredata_cname[] = {
0x02, 0x63, 0x6e, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03,
0x63, 0x6f, 0x6d, 0x00 };
@@ -50,16 +50,21 @@ const uint8_t wiredata_cname2[] = {
0x03, 0x63, 0x6e, 0x32, 0xc0, 0x03 };
TEST_F(Rdata_CNAME_Test, createFromText) {
- EXPECT_EQ(0, rdata_cname.compare(generic::CNAME("cn.example.com")));
+ EXPECT_EQ(0, rdata_cname.compare(generic::CNAME("cn.example.com.")));
// explicitly add a trailing dot. should be the same RDATA.
EXPECT_EQ(0, rdata_cname.compare(generic::CNAME("cn.example.com.")));
// should be case sensitive.
- EXPECT_EQ(0, rdata_cname.compare(generic::CNAME("CN.EXAMPLE.COM")));
+ EXPECT_EQ(0, rdata_cname.compare(generic::CNAME("CN.EXAMPLE.COM.")));
// RDATA of a class-independent type should be recognized for any
// "unknown" class.
EXPECT_EQ(0, rdata_cname.compare(*createRdata(RRType("CNAME"),
RRClass(65000),
- "cn.example.com")));
+ "cn.example.com.")));
+}
+
+TEST_F(Rdata_CNAME_Test, badText) {
+ // Extra text at end of line
+ EXPECT_THROW(generic::CNAME("cname.example.com. extra."), InvalidRdataText);
}
TEST_F(Rdata_CNAME_Test, createFromWire) {
@@ -79,7 +84,7 @@ TEST_F(Rdata_CNAME_Test, createFromWire) {
"rdata_cname_fromWire", 71),
DNSMessageFORMERR);
- EXPECT_EQ(0, generic::CNAME("cn2.example.com").compare(
+ EXPECT_EQ(0, generic::CNAME("cn2.example.com.").compare(
*rdataFactoryFromFile(RRType("CNAME"), RRClass("IN"),
"rdata_cname_fromWire", 55)));
EXPECT_THROW(*rdataFactoryFromFile(RRType("CNAME"), RRClass("IN"),
@@ -90,7 +95,17 @@ TEST_F(Rdata_CNAME_Test, createFromWire) {
TEST_F(Rdata_CNAME_Test, createFromLexer) {
EXPECT_EQ(0, rdata_cname.compare(
*test::createRdataUsingLexer(RRType::CNAME(), RRClass::IN(),
- "cn.example.com")));
+ "cn.example.com.")));
+
+ // test::createRdataUsingLexer() constructs relative to
+ // "example.org." origin.
+ EXPECT_EQ(0, generic::CNAME("cname10.example.org.").compare(
+ *test::createRdataUsingLexer(RRType::CNAME(), RRClass::IN(),
+ "cname10")));
+
+ // Extra text at end of line
+ EXPECT_FALSE(test::createRdataUsingLexer(RRType::CNAME(), RRClass::IN(),
+ "cname.example.com. extra."));
}
TEST_F(Rdata_CNAME_Test, toWireBuffer) {
diff --git a/src/lib/dns/tests/rdata_dname_unittest.cc b/src/lib/dns/tests/rdata_dname_unittest.cc
index c4e517c..5b6d9ac 100644
--- a/src/lib/dns/tests/rdata_dname_unittest.cc
+++ b/src/lib/dns/tests/rdata_dname_unittest.cc
@@ -36,8 +36,8 @@ class Rdata_DNAME_Test : public RdataTest {
// there's nothing to specialize
};
-const generic::DNAME rdata_dname("dn.example.com");
-const generic::DNAME rdata_dname2("dn2.example.com");
+const generic::DNAME rdata_dname("dn.example.com.");
+const generic::DNAME rdata_dname2("dn2.example.com.");
const uint8_t wiredata_dname[] = {
0x02, 0x64, 0x6e, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03,
0x63, 0x6f, 0x6d, 0x00 };
@@ -52,16 +52,21 @@ const uint8_t wiredata_dname2[] = {
0x63, 0x6f, 0x6d, 0x00 };
TEST_F(Rdata_DNAME_Test, createFromText) {
- EXPECT_EQ(0, rdata_dname.compare(generic::DNAME("dn.example.com")));
+ EXPECT_EQ(0, rdata_dname.compare(generic::DNAME("dn.example.com.")));
// explicitly add a trailing dot. should be the same RDATA.
EXPECT_EQ(0, rdata_dname.compare(generic::DNAME("dn.example.com.")));
// should be case sensitive.
- EXPECT_EQ(0, rdata_dname.compare(generic::DNAME("DN.EXAMPLE.COM")));
+ EXPECT_EQ(0, rdata_dname.compare(generic::DNAME("DN.EXAMPLE.COM.")));
// RDATA of a class-independent type should be recognized for any
// "unknown" class.
EXPECT_EQ(0, rdata_dname.compare(*createRdata(RRType("DNAME"),
RRClass(65000),
- "dn.example.com")));
+ "dn.example.com.")));
+}
+
+TEST_F(Rdata_DNAME_Test, badText) {
+ // Extra text at end of line
+ EXPECT_THROW(generic::DNAME("dname.example.com. extra."), InvalidRdataText);
}
TEST_F(Rdata_DNAME_Test, createFromWire) {
@@ -81,7 +86,7 @@ TEST_F(Rdata_DNAME_Test, createFromWire) {
"rdata_dname_fromWire", 71),
DNSMessageFORMERR);
- EXPECT_EQ(0, generic::DNAME("dn2.example.com").compare(
+ EXPECT_EQ(0, generic::DNAME("dn2.example.com.").compare(
*rdataFactoryFromFile(RRType("DNAME"), RRClass("IN"),
"rdata_dname_fromWire", 55)));
EXPECT_THROW(*rdataFactoryFromFile(RRType("DNAME"), RRClass("IN"),
@@ -92,7 +97,17 @@ TEST_F(Rdata_DNAME_Test, createFromWire) {
TEST_F(Rdata_DNAME_Test, createFromLexer) {
EXPECT_EQ(0, rdata_dname.compare(
*test::createRdataUsingLexer(RRType::DNAME(), RRClass::IN(),
- "dn.example.com")));
+ "dn.example.com.")));
+
+ // test::createRdataUsingLexer() constructs relative to
+ // "example.org." origin.
+ EXPECT_EQ(0, generic::DNAME("dname8.example.org.").compare(
+ *test::createRdataUsingLexer(RRType::DNAME(), RRClass::IN(),
+ "dname8")));
+
+ // Extra text at end of line
+ EXPECT_FALSE(test::createRdataUsingLexer(RRType::DNAME(), RRClass::IN(),
+ "dname.example.com. extra."));
}
TEST_F(Rdata_DNAME_Test, toWireBuffer) {
diff --git a/src/lib/dns/tests/rdata_srv_unittest.cc b/src/lib/dns/tests/rdata_srv_unittest.cc
index 066755f..a3d7721 100644
--- a/src/lib/dns/tests/rdata_srv_unittest.cc
+++ b/src/lib/dns/tests/rdata_srv_unittest.cc
@@ -39,7 +39,7 @@ class Rdata_SRV_Test : public RdataTest {
string srv_txt("1 5 1500 a.example.com.");
string srv_txt2("1 5 1400 example.com.");
string too_long_label("012345678901234567890123456789"
- "0123456789012345678901234567890123");
+ "0123456789012345678901234567890123.");
// 1 5 1500 a.example.com.
const uint8_t wiredata_srv[] = {
@@ -78,6 +78,8 @@ TEST_F(Rdata_SRV_Test, badText) {
// bad name
EXPECT_THROW(in::SRV("1 5 1500 a.example.com." + too_long_label),
TooLongLabel);
+ // Extra text at end of line
+ EXPECT_THROW(in::SRV("1 5 1500 a.example.com. extra."), InvalidRdataText);
}
TEST_F(Rdata_SRV_Test, assignment) {
@@ -124,10 +126,29 @@ TEST_F(Rdata_SRV_Test, createFromLexer) {
*test::createRdataUsingLexer(RRType::SRV(), RRClass::IN(),
"1 5 1500 a.example.com.")));
+ // test::createRdataUsingLexer() constructs relative to
+ // "example.org." origin.
+ EXPECT_EQ(0, in::SRV("1 5 1500 server16.example.org.").compare(
+ *test::createRdataUsingLexer(RRType::SRV(), RRClass::IN(),
+ "1 5 1500 server16")));
+
// Exceptions cause NULL to be returned.
+
+ // Bad priority
+ EXPECT_FALSE(test::createRdataUsingLexer(RRType::SRV(), RRClass::IN(),
+ "65536 5 1500 "
+ "a.example.com."));
+ // Bad weight
+ EXPECT_FALSE(test::createRdataUsingLexer(RRType::SRV(), RRClass::IN(),
+ "1 65536 1500 "
+ "a.example.com."));
+ // Bad port
EXPECT_FALSE(test::createRdataUsingLexer(RRType::SRV(), RRClass::IN(),
"1 5 281474976710656 "
"a.example.com."));
+ // Extra text at end of line
+ EXPECT_FALSE(test::createRdataUsingLexer(RRType::SRV(), RRClass::IN(),
+ "1 5 1500 a.example.com. extra."));
}
TEST_F(Rdata_SRV_Test, toWireBuffer) {
diff --git a/src/lib/dns/tests/zone_checker_unittest.cc b/src/lib/dns/tests/zone_checker_unittest.cc
index 115587f..320cda6 100644
--- a/src/lib/dns/tests/zone_checker_unittest.cc
+++ b/src/lib/dns/tests/zone_checker_unittest.cc
@@ -218,7 +218,7 @@ TEST_F(ZoneCheckerTest, checkNSData) {
// If there's a CNAME at the name instead, it's an error.
rrsets_->removeRRset(Name("*.example.com"), zclass_, RRType::A());
RRsetPtr cname(new RRset(ns_name, zclass_, RRType::CNAME(), RRTTL(60)));
- cname->addRdata(generic::CNAME("cname.example.com"));
+ cname->addRdata(generic::CNAME("cname.example.com."));
rrsets_->addRRset(cname);
EXPECT_FALSE(checkZone(zname_, zclass_, *rrsets_, callbacks_));
expected_errors_.push_back("zone example.com/IN: NS 'ns.example.com' is "
@@ -309,7 +309,7 @@ TEST_F(ZoneCheckerTest, checkNSWithDNAME) {
ns_->addRdata(generic::NS(ns_name));
rrsets_->addRRset(ns_);
RRsetPtr dname(new RRset(zname_, zclass_, RRType::DNAME(), RRTTL(60)));
- dname->addRdata(generic::DNAME("example.org"));
+ dname->addRdata(generic::DNAME("example.org."));
rrsets_->addRRset(dname);
EXPECT_FALSE(checkZone(zname_, zclass_, *rrsets_, callbacks_));
expected_errors_.push_back("zone example.com/IN: NS 'ns.child.example.com'"
@@ -320,7 +320,7 @@ TEST_F(ZoneCheckerTest, checkNSWithDNAME) {
rrsets_->removeRRset(zname_, zclass_, RRType::DNAME());
dname.reset(new RRset(Name("child.example.com"), zclass_, RRType::DNAME(),
RRTTL(60)));
- dname->addRdata(generic::DNAME("example.org"));
+ dname->addRdata(generic::DNAME("example.org."));
rrsets_->addRRset(dname);
EXPECT_FALSE(checkZone(zname_, zclass_, *rrsets_, callbacks_));
expected_errors_.push_back("zone example.com/IN: NS 'ns.child.example.com'"
@@ -342,7 +342,7 @@ TEST_F(ZoneCheckerTest, checkNSWithDNAME) {
rrsets_->removeRRset(dname->getName(), zclass_, RRType::DNAME());
rrsets_->removeRRset(ns_->getName(), zclass_, RRType::NS());
dname.reset(new RRset(ns_name, zclass_, RRType::DNAME(), RRTTL(60)));
- dname->addRdata(generic::DNAME("example.org"));
+ dname->addRdata(generic::DNAME("example.org."));
rrsets_->addRRset(dname);
EXPECT_TRUE(checkZone(zname_, zclass_, *rrsets_, callbacks_));
expected_warns_.push_back("zone example.com/IN: NS has no address");
diff --git a/src/lib/python/isc/testutils/rrset_utils.py b/src/lib/python/isc/testutils/rrset_utils.py
index 7eac772..7d54063 100644
--- a/src/lib/python/isc/testutils/rrset_utils.py
+++ b/src/lib/python/isc/testutils/rrset_utils.py
@@ -53,7 +53,7 @@ def create_ns(nsname, name=Name('example.com'), ttl=3600):
rrset.add_rdata(Rdata(RRType.NS(), RRClass.IN(), nsname))
return rrset
-def create_cname(target='target.example.com', name=Name('example.com'),
+def create_cname(target='target.example.com.', name=Name('example.com'),
ttl=3600):
rrset = RRset(name, RRClass.IN(), RRType.CNAME(), RRTTL(ttl))
rrset.add_rdata(Rdata(RRType.CNAME(), RRClass.IN(), target))
diff --git a/src/lib/resolve/tests/response_classifier_unittest.cc b/src/lib/resolve/tests/response_classifier_unittest.cc
index 23c8666..30aeabb 100644
--- a/src/lib/resolve/tests/response_classifier_unittest.cc
+++ b/src/lib/resolve/tests/response_classifier_unittest.cc
@@ -131,9 +131,9 @@ public:
// ... the CNAME records
rrs_in_cname_www1->addRdata(ConstRdataPtr(
- new CNAME("www.example.com")));
+ new CNAME("www.example.com.")));
rrs_in_cname_www2->addRdata(ConstRdataPtr(
- new CNAME("www1.example.com")));
+ new CNAME("www1.example.com.")));
}
Message msg_a; // Pointer to message in RENDER state
More information about the bind10-changes
mailing list