BIND 10 trac2387, updated. fb7adf34e96efc9c2e0986ab3f567c6d38500a89 [2387] Update NSEC3PARAM string RDATA constructor to use MasterLexer
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Mar 12 02:32:47 UTC 2013
The branch, trac2387 has been updated
via fb7adf34e96efc9c2e0986ab3f567c6d38500a89 (commit)
from 0c8f4051f57e4e1bcc29436bf50a1f7d4ff9e79d (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 fb7adf34e96efc9c2e0986ab3f567c6d38500a89
Author: Mukund Sivaraman <muks at isc.org>
Date: Tue Mar 12 07:56:08 2013 +0530
[2387] Update NSEC3PARAM string RDATA constructor to use MasterLexer
Also adjust tests.
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/rdata/generic/nsec3param_51.cc | 31 +++++++++++++++---------
src/lib/dns/rdata/generic/nsec3param_51.h | 4 +++
src/lib/dns/tests/rdata_nsec3param_unittest.cc | 8 +++---
3 files changed, 29 insertions(+), 14 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dns/rdata/generic/nsec3param_51.cc b/src/lib/dns/rdata/generic/nsec3param_51.cc
index e0a0f58..0a41048 100644
--- a/src/lib/dns/rdata/generic/nsec3param_51.cc
+++ b/src/lib/dns/rdata/generic/nsec3param_51.cc
@@ -49,24 +49,33 @@ struct NSEC3PARAMImpl {
NSEC3PARAM::NSEC3PARAM(const std::string& nsec3param_str) :
impl_(NULL)
{
- istringstream iss(nsec3param_str);
- vector<uint8_t> salt;
- const ParseNSEC3ParamResult params =
- parseNSEC3ParamText("NSEC3PARAM", nsec3param_str, iss, salt);
-
- if (!iss.eof()) {
- isc_throw(InvalidRdataText, "Invalid NSEC3PARAM (redundant text): "
- << nsec3param_str);
+ try {
+ std::istringstream ss(nsec3param_str);
+ MasterLexer lexer;
+ lexer.pushSource(ss);
+
+ constructFromLexer(lexer);
+
+ if (lexer.getNextToken().getType() != MasterToken::END_OF_FILE) {
+ isc_throw(InvalidRdataText,
+ "Extra input text for NSEC3PARAM: " << nsec3param_str);
+ }
+ } catch (const MasterLexer::LexerError& ex) {
+ isc_throw(InvalidRdataText,
+ "Failed to construct NSEC3PARAM from '" << nsec3param_str
+ << "': " << ex.what());
}
-
- impl_ = new NSEC3PARAMImpl(params.algorithm, params.flags,
- params.iterations, salt);
}
NSEC3PARAM::NSEC3PARAM(MasterLexer& lexer, const Name*, MasterLoader::Options,
MasterLoaderCallbacks&) :
impl_(NULL)
{
+ constructFromLexer(lexer);
+}
+
+void
+NSEC3PARAM::constructFromLexer(MasterLexer& lexer) {
vector<uint8_t> salt;
const ParseNSEC3ParamResult params =
parseNSEC3ParamFromLexer("NSEC3PARAM", lexer, salt);
diff --git a/src/lib/dns/rdata/generic/nsec3param_51.h b/src/lib/dns/rdata/generic/nsec3param_51.h
index 130c759..f371d7b 100644
--- a/src/lib/dns/rdata/generic/nsec3param_51.h
+++ b/src/lib/dns/rdata/generic/nsec3param_51.h
@@ -21,6 +21,7 @@
#include <dns/rrtype.h>
#include <dns/rrttl.h>
#include <dns/rdata.h>
+#include <dns/master_lexer.h>
// BEGIN_HEADER_GUARD
@@ -47,7 +48,10 @@ public:
uint8_t getFlags() const;
uint16_t getIterations() const;
const std::vector<uint8_t>& getSalt() const;
+
private:
+ void constructFromLexer(isc::dns::MasterLexer& lexer);
+
NSEC3PARAMImpl* impl_;
};
diff --git a/src/lib/dns/tests/rdata_nsec3param_unittest.cc b/src/lib/dns/tests/rdata_nsec3param_unittest.cc
index 115d3d3..88728de 100644
--- a/src/lib/dns/tests/rdata_nsec3param_unittest.cc
+++ b/src/lib/dns/tests/rdata_nsec3param_unittest.cc
@@ -58,12 +58,14 @@ TEST_F(Rdata_NSEC3PARAM_Test, fromText) {
TEST_F(Rdata_NSEC3PARAM_Test, toText) {
const generic::NSEC3PARAM rdata_nsec3param(nsec3param_txt);
EXPECT_EQ(nsec3param_txt, rdata_nsec3param.toText());
+
+ // Garbage space at the end should be ok. RFC5155 only forbids
+ // whitespace within the salt field, but any whitespace afterwards
+ // should be fine.
+ EXPECT_NO_THROW(generic::NSEC3PARAM("1 1 1 D399EAAB "));
}
TEST_F(Rdata_NSEC3PARAM_Test, badText) {
- // garbage space at the end
- EXPECT_THROW(generic::NSEC3PARAM("1 1 1 D399EAAB "),
- InvalidRdataText);
}
TEST_F(Rdata_NSEC3PARAM_Test, createFromWire) {
More information about the bind10-changes
mailing list