BIND 10 trac2500, updated. a095d57b989aca503c22bfe2121df389abdbd392 [2500] added notes that MNAME/RNAME must not be quoted string.
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Jan 9 21:38:24 UTC 2013
The branch, trac2500 has been updated
via a095d57b989aca503c22bfe2121df389abdbd392 (commit)
via a8e4e8678710187bbd044689a0ed603f5182fda8 (commit)
from 042731613c48d83d96bd3a4911b397977ae783dc (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 a095d57b989aca503c22bfe2121df389abdbd392
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Wed Jan 9 13:38:10 2013 -0800
[2500] added notes that MNAME/RNAME must not be quoted string.
commit a8e4e8678710187bbd044689a0ed603f5182fda8
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Wed Jan 9 13:37:14 2013 -0800
[2500] extracted createName() from soa.cc so it can be commonly used.
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/Makefile.am | 1 +
src/lib/dns/rdata/generic/detail/lexer_util.h | 70 +++++++++++++++++++++++++
src/lib/dns/rdata/generic/soa_6.cc | 23 ++++----
src/lib/dns/tests/rdata_soa_unittest.cc | 7 +++
4 files changed, 89 insertions(+), 12 deletions(-)
create mode 100644 src/lib/dns/rdata/generic/detail/lexer_util.h
-----------------------------------------------------------------------
diff --git a/src/lib/dns/Makefile.am b/src/lib/dns/Makefile.am
index 8525842..d843272 100644
--- a/src/lib/dns/Makefile.am
+++ b/src/lib/dns/Makefile.am
@@ -23,6 +23,7 @@ EXTRA_DIST += rdata/generic/cname_5.cc
EXTRA_DIST += rdata/generic/cname_5.h
EXTRA_DIST += rdata/generic/detail/char_string.cc
EXTRA_DIST += rdata/generic/detail/char_string.h
+EXTRA_DIST += rdata/generic/detail/lexer_util.h
EXTRA_DIST += rdata/generic/detail/nsec_bitmap.cc
EXTRA_DIST += rdata/generic/detail/nsec_bitmap.h
EXTRA_DIST += rdata/generic/detail/nsec3param_common.cc
diff --git a/src/lib/dns/rdata/generic/detail/lexer_util.h b/src/lib/dns/rdata/generic/detail/lexer_util.h
new file mode 100644
index 0000000..89df5a0
--- /dev/null
+++ b/src/lib/dns/rdata/generic/detail/lexer_util.h
@@ -0,0 +1,70 @@
+// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef DNS_RDATA_LEXER_UTIL_H
+#define DNS_RDATA_LEXER_UTIL_H 1
+
+#include <dns/name.h>
+#include <dns/master_lexer.h>
+
+/// \file lexer_util.h
+/// \brief Utilities for extracting RDATA fields from lexer.
+///
+/// This file intends to define convenient small routines that can be
+/// commonly used in the RDATA implementation to build RDATA fields from
+/// a \c MasterLexer.
+
+namespace isc {
+namespace dns {
+namespace rdata {
+namespace generic {
+namespace detail {
+
+/// \brief Construct a Name object using a master lexer and optional origin.
+///
+/// This is a convenient shortcut of commonly used code pattern that would
+/// be used to build RDATA that contain a domain name field.
+///
+/// Note that this function throws an exception against invalid input.
+/// The (direct or indirect) caller's responsibility needs to expect and
+/// handle exceptions appropriately.
+///
+/// \throw MasterLexer::LexerError The next token from lexer is not string.
+/// \throw Other Exceptions from the \c Name class constructor if the next
+/// string token from the lexer does not represent a valid name.
+///
+/// \param lexer A \c MasterLexer object. Its next token is expected to be
+/// a string that represent a domain name.
+/// \param origin If non NULL, specifies the origin of the name to be
+/// constructed.
+///
+/// \return A new Name object that corresponds to the next string token of
+/// the \c lexer.
+inline Name
+createNameFromLexer(MasterLexer& lexer, const Name* origin) {
+ const MasterToken::StringRegion& str_region =
+ lexer.getNextToken(MasterToken::STRING).getStringRegion();
+ return (Name(str_region.beg, str_region.len, origin));
+}
+
+} // namespace detail
+} // namespace generic
+} // namespace rdata
+} // namespace dns
+} // namespace isc
+#endif // DNS_RDATA_LEXER_UTIL_H
+
+// Local Variables:
+// mode: c++
+// End:
diff --git a/src/lib/dns/rdata/generic/soa_6.cc b/src/lib/dns/rdata/generic/soa_6.cc
index 4c95c51..56eb7a2 100644
--- a/src/lib/dns/rdata/generic/soa_6.cc
+++ b/src/lib/dns/rdata/generic/soa_6.cc
@@ -25,6 +25,8 @@
#include <dns/rdata.h>
#include <dns/rdataclass.h>
+#include <dns/rdata/generic/detail/lexer_util.h>
+
#include <boost/static_assert.hpp>
#include <boost/lexical_cast.hpp>
@@ -34,6 +36,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
@@ -47,13 +50,6 @@ SOA::SOA(InputBuffer& buffer, size_t) :
}
namespace {
-Name
-createName(MasterLexer& lexer, const Name* origin) {
- const MasterToken::StringRegion& str_region =
- lexer.getNextToken(MasterToken::STRING).getStringRegion();
- return (Name(str_region.beg, str_region.len, origin));
-}
-
void
fillParameters(MasterLexer& lexer, uint8_t numdata[20]) {
// Copy serial, refresh, retry, expire, minimum. We accept the extended
@@ -77,13 +73,15 @@ fillParameters(MasterLexer& lexer, uint8_t numdata[20]) {
///
/// The MNAME and RNAME must be absolute since there's no parameter that
/// specifies the origin name; if these are not absolute, \c MissingNameOrigin
-/// exception will be thrown.
+/// exception will be thrown. These 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.
SOA::SOA(const std::string& soastr) :
+ // Fill in dummy name and replace them soon below.
mname_(Name::ROOT_NAME()), rname_(Name::ROOT_NAME())
{
try {
@@ -91,8 +89,8 @@ SOA::SOA(const std::string& soastr) :
MasterLexer lexer;
lexer.pushSource(ss);
- mname_ = createName(lexer, NULL);
- rname_ = createName(lexer, NULL);
+ mname_ = createNameFromLexer(lexer, NULL);
+ rname_ = createNameFromLexer(lexer, NULL);
fillParameters(lexer, numdata_);
if (lexer.getNextToken().getType() != MasterToken::END_OF_FILE) {
@@ -110,7 +108,7 @@ SOA::SOA(const std::string& soastr) :
/// The \c lexer should point to the beginning of valid textual representation
/// of an SOA RDATA. The MNAME and RNAME fields can be non absolute if
/// \c origin is non NULL, in which case \c origin is used to make them
-/// absolute.
+/// absolute. These must not be represented as a quoted string.
///
/// The REFRESH, RETRY, EXPIRE, and MINIMUM fields can be either a valid
/// decimal representation of an unsigned 32-bit integer or other
@@ -126,7 +124,8 @@ SOA::SOA(const std::string& soastr) :
/// they are non absolute.
SOA::SOA(MasterLexer& lexer, const Name* origin,
MasterLoader::Options, MasterLoaderCallbacks&) :
- mname_(createName(lexer, origin)), rname_(createName(lexer, origin))
+ mname_(createNameFromLexer(lexer, origin)),
+ rname_(createNameFromLexer(lexer, origin))
{
fillParameters(lexer, numdata_);
}
diff --git a/src/lib/dns/tests/rdata_soa_unittest.cc b/src/lib/dns/tests/rdata_soa_unittest.cc
index dedb1f9..ed1c29f 100644
--- a/src/lib/dns/tests/rdata_soa_unittest.cc
+++ b/src/lib/dns/tests/rdata_soa_unittest.cc
@@ -106,6 +106,13 @@ TEST_F(Rdata_SOA_Test, createFromText) {
checkFromBadTexxt<EmptyLabel, EmptyLabel>(
". bad..example. 2010012601 1H 5M 1000H 20M");
+ // Names shouldn't be quoted. (Note: on completion of #2534, the resulting
+ // exception will be different).
+ checkFromBadTexxt<MissingNameOrigin, MissingNameOrigin>(
+ "\".\" . 0 0 0 0 0");
+ checkFromBadTexxt<MissingNameOrigin, MissingNameOrigin>(
+ ". \".\" 0 0 0 0 0");
+
// Missing MAME or RNAME: for the string version, the serial would be
// tried as RNAME and result in "not absolute". For the lexer version,
// it reaches the end-of-line, missing min TTL.
More information about the bind10-changes
mailing list