BIND 10 master, updated. 055622f347c9e5beb43a5145c82a4f4a54e89d4b [master] Merge branch 'master' of ssh://git.bind10.isc.org/var/bind10/git/bind10

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Feb 29 13:05:41 UTC 2012


The branch, master has been updated
       via  055622f347c9e5beb43a5145c82a4f4a54e89d4b (commit)
       via  a9d6dd7cab00acd5379309d94ecb8b088ca3d295 (commit)
       via  a756c801315d320a855f312da4cad370e52371e3 (commit)
       via  e202628c6950839aaa6d318ea7a08b4f596499c0 (commit)
       via  7b92c815b458b3fb4011fede59b787391bec7058 (commit)
      from  a7f978695cb84f9be3dd4ca4ff819c85d4477746 (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 055622f347c9e5beb43a5145c82a4f4a54e89d4b
Merge: a9d6dd7cab00acd5379309d94ecb8b088ca3d295 a7f978695cb84f9be3dd4ca4ff819c85d4477746
Author: Jelte Jansen <jelte at isc.org>
Date:   Wed Feb 29 14:05:32 2012 +0100

    [master] Merge branch 'master' of ssh://git.bind10.isc.org/var/bind10/git/bind10

commit a9d6dd7cab00acd5379309d94ecb8b088ca3d295
Author: Jelte Jansen <jelte at isc.org>
Date:   Wed Feb 29 13:59:15 2012 +0100

    [1722] update test comment

commit a756c801315d320a855f312da4cad370e52371e3
Author: Jelte Jansen <jelte at isc.org>
Date:   Wed Feb 29 12:12:50 2012 +0100

    [1722] fix tab escape in whitespace replacer

commit e202628c6950839aaa6d318ea7a08b4f596499c0
Author: Jelte Jansen <jelte at isc.org>
Date:   Wed Feb 29 11:08:15 2012 +0100

    [1722] find_last does not need argument now

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

Summary of changes:
 src/lib/dns/masterload.cc                |   26 +++++++---------
 src/lib/dns/tests/masterload_unittest.cc |   48 ++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 14 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/masterload.cc b/src/lib/dns/masterload.cc
index a228581..0b195f6 100644
--- a/src/lib/dns/masterload.cc
+++ b/src/lib/dns/masterload.cc
@@ -38,26 +38,25 @@ using namespace isc::dns::rdata;
 namespace isc {
 namespace dns {
 namespace {
-// A helper function that strips off any comment placed at the end of an RR.
+// A helper function that strips off any comment or whitespace at the end of
+// an RR.
 // This is an incomplete implementation, and cannot handle all such comments;
 // it's considered a short term workaround to deal with some real world
 // cases.
 string
-stripComment(string& s, const Exception& ex) {
+stripLine(string& s, const Exception& ex) {
     // Find any ';' in the text data, and locate the position of the last
     // occurrence.  Note that unless/until we support empty RDATA it
     // shouldn't be placed at the beginning of the data.
     const size_t pos_semicolon = s.rfind(';');
-    if (pos_semicolon == string::npos || pos_semicolon == 0) {
+    if (pos_semicolon == 0) {
         throw ex;
+    } else if (pos_semicolon != string::npos) {
+        s.resize(pos_semicolon);
     }
-    // Remove any trailing space and comments and return the resulting text.
-    const size_t pos_end_data = s.find_last_not_of(" /t", pos_semicolon - 1);
-    if (pos_end_data != string::npos) {
-        s.erase(pos_end_data + 1);
-        return (s);
-    }
-    throw ex;
+    // Remove any trailing whitespace return the resulting text.
+    s.resize(s.find_last_not_of(" \t") + 1);
+    return (s);
 }
 }
 
@@ -145,10 +144,9 @@ masterLoad(istream& input, const Name& origin, const RRClass& zone_class,
                 rdata = createRdata(*rrtype, *rrclass, rdtext);
             } catch (const Exception& ex) {
                 // If the parse for the RDATA fails, check if it has comments
-                // at the end, and if so, retry the conversion after stripping
-                // off the comment.
-                rdata = createRdata(*rrtype, *rrclass, stripComment(rdtext,
-                                                                    ex));
+                // or whitespace at the end, and if so, retry the conversion
+                // after stripping off the comment or whitespace
+                rdata = createRdata(*rrtype, *rrclass, stripLine(rdtext, ex));
             }
         } catch (const Exception& ex) {
             isc_throw(MasterLoadError, "Invalid RR text at line " << line_count
diff --git a/src/lib/dns/tests/masterload_unittest.cc b/src/lib/dns/tests/masterload_unittest.cc
index 35db48c..95ce6f3 100644
--- a/src/lib/dns/tests/masterload_unittest.cc
+++ b/src/lib/dns/tests/masterload_unittest.cc
@@ -193,6 +193,54 @@ TEST_F(MasterLoadTest, loadRRWithCommentNoSpace) {
                                       dnskey_rdata)));
 }
 
+TEST_F(MasterLoadTest, loadRRWithCommentEmptyComment) {
+    // Similar to the previous one, but there's no data after the ;
+    // It should still work.
+    rr_stream << "example.com. 3600 IN DNSKEY	256 3 7 "
+        "AwEAAaetidLzsKWUt4swWR8yu0wPHPiUi8LUsAD0QPWU+wzt89epO6tH "
+        "zkMBVDkC7qphQO2hTY4hHn9npWFRw5BYubE= ;\n";
+    masterLoad(rr_stream, origin, zclass, callback);
+    ASSERT_EQ(1, results.size());
+    EXPECT_EQ(0, results[0]->getRdataIterator()->getCurrent().compare(
+                  *rdata::createRdata(RRType::DNSKEY(), zclass,
+                                      dnskey_rdata)));
+}
+
+TEST_F(MasterLoadTest, loadRRWithCommentEmptyCommentNoSpace) {
+    // Similar to the previous one, but there's no space before or after ;
+    // It should still work.
+    rr_stream << "example.com. 3600 IN DNSKEY	256 3 7 "
+        "AwEAAaetidLzsKWUt4swWR8yu0wPHPiUi8LUsAD0QPWU+wzt89epO6tH "
+        "zkMBVDkC7qphQO2hTY4hHn9npWFRw5BYubE=;\n";
+    masterLoad(rr_stream, origin, zclass, callback);
+    ASSERT_EQ(1, results.size());
+    EXPECT_EQ(0, results[0]->getRdataIterator()->getCurrent().compare(
+                  *rdata::createRdata(RRType::DNSKEY(), zclass,
+                                      dnskey_rdata)));
+}
+
+TEST_F(MasterLoadTest, loadRRWithEOLWhitespace) {
+    // Test with whitespace after rdata
+    // It should still work.
+    rr_stream << "example.com. 3600 IN NSEC3PARAM 1 0 1 beef \n";
+    masterLoad(rr_stream, origin, zclass, callback);
+    ASSERT_EQ(1, results.size());
+    EXPECT_EQ(0, results[0]->getRdataIterator()->getCurrent().compare(
+                  *rdata::createRdata(RRType::NSEC3PARAM(), zclass,
+                                      "1 0 1 beef")));
+}
+
+TEST_F(MasterLoadTest, loadRRWithEOLWhitespaceTab) {
+    // Similar to the previous one, tab instead of space.
+    // It should still work.
+    rr_stream << "example.com. 3600 IN NSEC3PARAM 1 0 1 beef\t\n";
+    masterLoad(rr_stream, origin, zclass, callback);
+    ASSERT_EQ(1, results.size());
+    EXPECT_EQ(0, results[0]->getRdataIterator()->getCurrent().compare(
+                  *rdata::createRdata(RRType::NSEC3PARAM(), zclass,
+                                      "1 0 1 beef")));
+}
+
 TEST_F(MasterLoadTest, loadRRNoComment) {
     // A semicolon in a character-string shouldn't confuse the parser.
     rr_stream << "example.com. 3600 IN TXT \"aaa;bbb\"\n";



More information about the bind10-changes mailing list