BIND 10 trac1641, updated. 0aef7c479e7d127d0c219d6b3a5a4d0f3f701161 [1641] added some detailed description for compareVectors used in NSEC3 implementation.

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Feb 13 19:14:08 UTC 2012


The branch, trac1641 has been updated
       via  0aef7c479e7d127d0c219d6b3a5a4d0f3f701161 (commit)
       via  eaff1f5816bd2ed57a011f658e0b2dd762800079 (commit)
       via  2a29f6b8725bf106dce2f45f2705bac555022c5d (commit)
       via  9ff58bb76e632a8f7a28a4f86f94dd1d77690796 (commit)
       via  a9eadb451bea1a4813a7b3942a7ca2eea97618a5 (commit)
       via  ddaaee4b050468048409170f1bb56530f33567d6 (commit)
      from  9e3c7d57f3144b6992d8967af5a4583aa3d55c62 (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 0aef7c479e7d127d0c219d6b3a5a4d0f3f701161
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Mon Feb 13 11:13:27 2012 -0800

    [1641] added some detailed description for compareVectors used in NSEC3 implementation.

commit eaff1f5816bd2ed57a011f658e0b2dd762800079
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Mon Feb 13 10:59:30 2012 -0800

    [1641] editorial cleanup: removed unnecessary ','

commit 2a29f6b8725bf106dce2f45f2705bac555022c5d
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Mon Feb 13 10:58:27 2012 -0800

    [1641] editorial cleanup: removed a redundant blank line

commit 9ff58bb76e632a8f7a28a4f86f94dd1d77690796
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Mon Feb 13 10:57:34 2012 -0800

    [1641] comment wording fix

commit a9eadb451bea1a4813a7b3942a7ca2eea97618a5
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Mon Feb 13 10:54:21 2012 -0800

    [1641] simplified a numerical order comparison

commit ddaaee4b050468048409170f1bb56530f33567d6
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Mon Feb 13 10:42:25 2012 -0800

    [1641] use cstring instead of string.h (the former is slightly better in terms
    of honoring C++ namespaces).

-----------------------------------------------------------------------

Summary of changes:
 src/lib/dns/rdata/generic/detail/nsec_bitmap.cc |    2 +-
 src/lib/dns/rdata/generic/nsec3_50.cc           |   18 +++++++++++++++++-
 src/lib/dns/tests/rdata_nsecbitmap_unittest.cc  |    6 +++---
 3 files changed, 21 insertions(+), 5 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/rdata/generic/detail/nsec_bitmap.cc b/src/lib/dns/rdata/generic/detail/nsec_bitmap.cc
index 86f2379..bb48705 100644
--- a/src/lib/dns/rdata/generic/detail/nsec_bitmap.cc
+++ b/src/lib/dns/rdata/generic/detail/nsec_bitmap.cc
@@ -21,8 +21,8 @@
 #include <cassert>
 #include <sstream>
 #include <vector>
+#include <cstring>
 #include <stdint.h>
-#include <string.h>
 
 using namespace std;
 
diff --git a/src/lib/dns/rdata/generic/nsec3_50.cc b/src/lib/dns/rdata/generic/nsec3_50.cc
index 84f6b90..3817941 100644
--- a/src/lib/dns/rdata/generic/nsec3_50.cc
+++ b/src/lib/dns/rdata/generic/nsec3_50.cc
@@ -234,6 +234,22 @@ NSEC3::toWire(AbstractMessageRenderer& renderer) const {
 }
 
 namespace {
+// This is a helper subroutine for compare().  It compares two binary
+// data stored in vector<uint8_t> objects based on the "Canonical RR Ordering"
+// as defined in Section 6.3 of RFC4034, that is, the data are treated
+// "as a left-justified unsigned octet sequence in which the absence of an
+// octet sorts before a zero octet."
+//
+// If check_length_first is true, it treats the compared data as if they
+// began with a single-octet "length" field whose value is the size of the
+// corresponding vector.  In this case, if the sizes of the two vectors are
+// different the shorter one is always considered the "smaller"; the contents
+// of the vector don't matter.
+//
+// This function returns:
+// -1 if v1 is considered smaller than v2
+// 1 if v1 is considered larger than v2
+// 0 otherwise
 int
 compareVectors(const vector<uint8_t>& v1, const vector<uint8_t>& v2,
                bool check_length_first = true)
@@ -242,7 +258,7 @@ compareVectors(const vector<uint8_t>& v1, const vector<uint8_t>& v2,
     const size_t len2 = v2.size();
     const size_t cmplen = min(len1, len2);
     if (check_length_first && len1 != len2) {
-        return (len1 < len2 ? -1 : 1);
+        return (len1 - len2);
     }
     const int cmp = cmplen == 0 ? 0 : memcmp(&v1.at(0), &v2.at(0), cmplen);
     if (cmp != 0) {
diff --git a/src/lib/dns/tests/rdata_nsecbitmap_unittest.cc b/src/lib/dns/tests/rdata_nsecbitmap_unittest.cc
index db0fc69..426a69e 100644
--- a/src/lib/dns/tests/rdata_nsecbitmap_unittest.cc
+++ b/src/lib/dns/tests/rdata_nsecbitmap_unittest.cc
@@ -174,7 +174,6 @@ TYPED_TEST(NSECLikeBitmapTest, badText) {
                  InvalidRdataText);
 }
 
-
 // This tests the result of toText() with various kinds of NSEC/NSEC3 bitmaps.
 // It also tests the "from text" constructor as a result.
 TYPED_TEST(NSECLikeBitmapTest, toText) {
@@ -186,7 +185,8 @@ TYPED_TEST(NSECLikeBitmapTest, toText) {
     rdata_text = this->getCommonText() + "NS DLV";
     EXPECT_EQ(rdata_text, this->fromText(rdata_text).toText());
 
-    // Make sure all possible bits in a one-octet bitmap field correctly.
+    // Make sure all possible bits in a one-octet bitmap field are handled
+    // correctly.
     // We use the range around 1024 (reasonably higher number) so it's
     // unlikely that they have predefined mnemonic and can be safely converted
     // to TYPEnnnn by toText().
@@ -213,7 +213,7 @@ TYPED_TEST(NSECLikeBitmapTest, compare) {
     // Bit map: [win=0][len=1] 00000010, [win=4][len=1] 10000000
     this->compare_set.push_back(this->fromText(this->getCommonText() +
                                                "SOA TYPE1024"));
-    // Bit map: [win=0][len=1] 00100000,
+    // Bit map: [win=0][len=1] 00100000
     this->compare_set.push_back(this->fromText(this->getCommonText() + "NS"));
     // Bit map: [win=0][len=1] 00100010
     this->compare_set.push_back(this->fromText(this->getCommonText() +




More information about the bind10-changes mailing list