BIND 10 trac2387, updated. 0ecc1e01cde7133bfcb183ced46b011b4eb9558a [2387] Support empty bitmaps in buildBitmapsFromLexer()
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Mar 25 10:40:53 UTC 2013
The branch, trac2387 has been updated
via 0ecc1e01cde7133bfcb183ced46b011b4eb9558a (commit)
from 09fff7c3f6d538b80e8a1760673bc4a3ac9f62d2 (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 0ecc1e01cde7133bfcb183ced46b011b4eb9558a
Author: Mukund Sivaraman <muks at isc.org>
Date: Mon Mar 25 16:10:08 2013 +0530
[2387] Support empty bitmaps in buildBitmapsFromLexer()
This avoids an extra ungetToken() and cuts down on some code too.
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/rdata/generic/detail/nsec_bitmap.cc | 6 +++++-
src/lib/dns/rdata/generic/detail/nsec_bitmap.h | 9 +++++++--
src/lib/dns/rdata/generic/nsec3_50.cc | 21 ++-------------------
3 files changed, 14 insertions(+), 22 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dns/rdata/generic/detail/nsec_bitmap.cc b/src/lib/dns/rdata/generic/detail/nsec_bitmap.cc
index c8a8461..a95d6c7 100644
--- a/src/lib/dns/rdata/generic/detail/nsec_bitmap.cc
+++ b/src/lib/dns/rdata/generic/detail/nsec_bitmap.cc
@@ -79,7 +79,8 @@ checkRRTypeBitmaps(const char* const rrtype_name,
void
buildBitmapsFromLexer(const char* const rrtype_name,
- MasterLexer& lexer, vector<uint8_t>& typebits)
+ MasterLexer& lexer, vector<uint8_t>& typebits,
+ bool allow_empty)
{
uint8_t bitmap[8 * 1024]; // 64k bits
memset(bitmap, 0, sizeof(bitmap));
@@ -112,6 +113,9 @@ buildBitmapsFromLexer(const char* const rrtype_name,
lexer.ungetToken();
if (!have_rrtypes) {
+ if (allow_empty) {
+ return;
+ }
isc_throw(InvalidRdataText,
rrtype_name << " record does not end with RR type mnemonic");
}
diff --git a/src/lib/dns/rdata/generic/detail/nsec_bitmap.h b/src/lib/dns/rdata/generic/detail/nsec_bitmap.h
index 7468225..5525384 100644
--- a/src/lib/dns/rdata/generic/detail/nsec_bitmap.h
+++ b/src/lib/dns/rdata/generic/detail/nsec_bitmap.h
@@ -57,7 +57,8 @@ void checkRRTypeBitmaps(const char* const rrtype_name,
/// \brief Convert textual sequence of RR types read from a lexer into
/// type bitmaps.
///
-/// See the other variant above for description.
+/// See the other variant above for description. If \c allow_empty is
+/// true and there are no mnemonics, \c typebits is left untouched.
///
/// \exception InvalidRdataText Data read from the given lexer does not
/// meet the assumption (e.g. including invalid form of RR type, not
@@ -70,9 +71,13 @@ void checkRRTypeBitmaps(const char* const rrtype_name,
/// bits are set.
/// \param typebits A placeholder for the resulting bitmaps. Expected to be
/// empty, but it's not checked.
+/// \param allow_empty If true, the function simply returns if no RR
+/// type mnemonics are found. Otherwise, it throws an exception if no RR
+/// type mnemonics are found.
void buildBitmapsFromLexer(const char* const rrtype_name,
isc::dns::MasterLexer& lexer,
- std::vector<uint8_t>& typebits);
+ std::vector<uint8_t>& typebits,
+ bool allow_empty = false);
/// \brief Convert type bitmaps to textual sequence of RR types.
///
diff --git a/src/lib/dns/rdata/generic/nsec3_50.cc b/src/lib/dns/rdata/generic/nsec3_50.cc
index 6c65cd2..51d72d8 100644
--- a/src/lib/dns/rdata/generic/nsec3_50.cc
+++ b/src/lib/dns/rdata/generic/nsec3_50.cc
@@ -144,26 +144,9 @@ NSEC3::constructFromLexer(MasterLexer& lexer) {
<< next.size() << " bytes");
}
- // For NSEC3 empty bitmap is possible and allowed.
- bool empty_bitmap = false;
- const MasterToken& token = lexer.getNextToken();
- if ((token.getType() == MasterToken::END_OF_LINE) ||
- (token.getType() == MasterToken::END_OF_FILE)) {
- empty_bitmap = true;
- }
-
- lexer.ungetToken();
-
- if (empty_bitmap) {
- impl_ = new NSEC3Impl(params.algorithm, params.flags,
- params.iterations, salt, next,
- vector<uint8_t>());
- return;
- }
-
vector<uint8_t> typebits;
- buildBitmapsFromLexer("NSEC3", lexer, typebits);
-
+ // For NSEC3 empty bitmap is possible and allowed.
+ buildBitmapsFromLexer("NSEC3", lexer, typebits, true);
impl_ = new NSEC3Impl(params.algorithm, params.flags, params.iterations,
salt, next, typebits);
}
More information about the bind10-changes
mailing list