BIND 10 trac2383, updated. cfcad4db4f9da2525f7c9cddcdd52660f60e4afa [2383] Append the origin if relative
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Oct 30 12:47:50 UTC 2012
The branch, trac2383 has been updated
via cfcad4db4f9da2525f7c9cddcdd52660f60e4afa (commit)
from b2d9be92c95432c92d4996bd999960e08edcc9bc (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 cfcad4db4f9da2525f7c9cddcdd52660f60e4afa
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Tue Oct 30 13:41:55 2012 +0100
[2383] Append the origin if relative
Add the origin to the parsed name if the parsed name is relative. Also,
add the checks for the combined length and fix a test for them.
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/name.cc | 31 +++++++++++++++++++++++++++++++
src/lib/dns/tests/name_unittest.cc | 2 +-
2 files changed, 32 insertions(+), 1 deletion(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dns/name.cc b/src/lib/dns/name.cc
index 6e6a704..11d5d12 100644
--- a/src/lib/dns/name.cc
+++ b/src/lib/dns/name.cc
@@ -353,6 +353,37 @@ Name::Name(const char* namedata, size_t data_len, const Name* origin,
ndata_.assign(ndata.data(), ndata.size());
length_ = ndata_.size();
offsets_.assign(offsets.begin(), offsets.end());
+
+ if (!absolute) {
+ // Now, extend the data with the ones from origin. But eat the
+ // last label (the empty one).
+
+ // Drop the last character of the data (the \0) and append a copy of
+ // the origin's data
+ ndata_.erase(ndata_.end() - 1);
+ ndata_.append(origin->ndata_);
+
+ // Do a similar thing with offsets. However, we need to move them
+ // so they point after the prefix we parsed before.
+ size_t offset = offsets_.back();
+ offsets_.pop_back();
+ size_t offset_count = offsets_.size();
+ offsets_.insert(offsets_.end(), origin->offsets_.begin(),
+ origin->offsets_.end());
+ for (NameOffsets::iterator it(offsets_.begin() + offset_count);
+ it != offsets_.end(); ++it) {
+ *it += offset;
+ }
+
+ // Adjust sizes.
+ length_ = ndata_.size();
+ labelcount_ = offsets_.size();
+
+ // And check the sizes are OK.
+ if (labelcount_ > Name::MAX_LABELS || length_ > Name::MAX_WIRE) {
+ isc_throw(TooLongName, "Combined name is too long");
+ }
+ }
}
namespace {
diff --git a/src/lib/dns/tests/name_unittest.cc b/src/lib/dns/tests/name_unittest.cc
index d2a1684..11ac929 100644
--- a/src/lib/dns/tests/name_unittest.cc
+++ b/src/lib/dns/tests/name_unittest.cc
@@ -47,7 +47,7 @@ const char* max_labels_str = "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9." // 40
"0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9." // 160
"0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9." // 200
"0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9." // 240
- "0.1.2.3.4.5.6.";
+ "0.1.2.3.4.5.6";
// This is a name of maximum allowed length
const char* max_len_str = "123456789.123456789.123456789.123456789.123456789."
"123456789.123456789.123456789.123456789.123456789."
More information about the bind10-changes
mailing list