BIND 10 trac2427, updated. 471c6f2d6c1ad9b71422f1d19b6223492c5b6023 [2427] Warn on ambiguous initial whitespace name

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Dec 17 13:07:01 UTC 2012


The branch, trac2427 has been updated
       via  471c6f2d6c1ad9b71422f1d19b6223492c5b6023 (commit)
      from  3adc5a448824ec9a819c52c89869855cf1de8d0c (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 471c6f2d6c1ad9b71422f1d19b6223492c5b6023
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Dec 17 14:06:20 2012 +0100

    [2427] Warn on ambiguous initial whitespace name
    
    Which happens after the $INCLUDE directive.

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

Summary of changes:
 src/lib/dns/master_loader.cc                |   11 +++++++++++
 src/lib/dns/tests/master_loader_unittest.cc |   21 ++++++++++++++++++++-
 2 files changed, 31 insertions(+), 1 deletion(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/master_loader.cc b/src/lib/dns/master_loader.cc
index 2548a48..254adb0 100644
--- a/src/lib/dns/master_loader.cc
+++ b/src/lib/dns/master_loader.cc
@@ -69,6 +69,7 @@ public:
         initialized_(false),
         ok_(true),
         many_errors_((options & MANY_ERRORS) != 0),
+        previous_name_(false),
         complete_(false),
         seen_error_(false)
     {}
@@ -101,6 +102,7 @@ public:
         // Store the current status, so we can recover it upon popSource
         include_info_.push_back(IncludeInfo(active_origin_, last_name_));
         initialized_ = true;
+        previous_name_ = false;
     }
 
     bool popSource() {
@@ -117,6 +119,7 @@ public:
         active_origin_ = info.first;
         last_name_ = info.second;
         include_info_.pop_back();
+        previous_name_ = false;
         return (true);
     }
 
@@ -238,6 +241,8 @@ private:
     // in that file.
     typedef pair<Name, shared_ptr<Name> > IncludeInfo;
     vector<IncludeInfo> include_info_;
+    bool previous_name_; // True if there was a previous name in this file
+                         // (false at the beginning or after an $INCLUDE line)
 public:
     bool complete_;             // All work done.
     bool seen_error_;           // Was there at least one error during the
@@ -312,11 +317,17 @@ MasterLoader::MasterLoaderImpl::loadIncremental(size_t count_limit) {
 
                 last_name_.reset(new Name(name_string.beg, name_string.len,
                                           &active_origin_));
+                previous_name_ = true;
             } else if (initial_token.getType() == MasterToken::INITIAL_WS) {
                 // This means the same name as previous.
                 if (last_name_.get() == NULL) {
                     isc_throw(InternalException, "No previous name to use in "
                               "place of initial whitespace");
+                } else if (!previous_name_) {
+                    callbacks_.warning(lexer_.getSourceName(),
+                                       lexer_.getSourceLine(),
+                                       "Ambiguous previous name previous name "
+                                       "for initial whitespace");
                 }
             } else if (initial_token.getType() == MasterToken::ERROR) {
                 // Error token here.
diff --git a/src/lib/dns/tests/master_loader_unittest.cc b/src/lib/dns/tests/master_loader_unittest.cc
index 9c75f3c..f983e9b 100644
--- a/src/lib/dns/tests/master_loader_unittest.cc
+++ b/src/lib/dns/tests/master_loader_unittest.cc
@@ -478,13 +478,32 @@ TEST_F(MasterLoaderTest, includeOriginRestore) {
     // Successfully load the data
     loader_->load();
     EXPECT_TRUE(loader_->loadedSucessfully());
-    EXPECT_TRUE(errors_.empty()) << errors_[0];
+    EXPECT_TRUE(errors_.empty());
     EXPECT_TRUE(warnings_.empty());
     // And check it's the correct data
     checkARR("www.example.org");
     checkARR("example.org");
 }
 
+// Check we restore the last name for initial whitespace when returning from
+// include. But we do produce a warning if there's one just ofter the include.
+TEST_F(MasterLoaderTest, includeAndInitialWS) {
+    const string include_string = "xyz  1H  IN  A   192.0.2.1\n"
+        "$INCLUDE " TEST_DATA_SRCDIR "/example.org\n"
+        "   1H  IN  A   192.0.2.1\n";
+    stringstream ss(include_string);
+    setLoader(ss, Name("example.org"), RRClass::IN(),
+              MasterLoader::MANY_ERRORS);
+    // Successfully load the data
+    loader_->load();
+    EXPECT_TRUE(loader_->loadedSucessfully());
+    EXPECT_TRUE(errors_.empty());
+    EXPECT_EQ(1, warnings_.size());
+    checkARR("xyz.example.org");
+    checkBasicRRs();
+    checkARR("xyz.example.org");
+}
+
 // Test the constructor rejects empty add callback.
 TEST_F(MasterLoaderTest, emptyCallback) {
     EXPECT_THROW(MasterLoader(TEST_DATA_SRCDIR "/example.org",



More information about the bind10-changes mailing list