Commit 37cc046b authored by JINMEI Tatuya's avatar JINMEI Tatuya Committed by Jelte Jansen
Browse files

[2380] make sure the new origin for $INCLUDE doesn't change post-include.

this seems to be the actual intent of the RFC, and it's compatible with
BIND 9, too.  This fix will resolve the remaining regression for the
old loadzone tests.
parent a51b0404
......@@ -79,7 +79,7 @@ public:
void pushSource(const std::string& filename) {
void pushSource(const std::string& filename, const Name& current_origin) {
std::string error;
if (!lexer_.pushSource(filename.c_str(), &error)) {
if (initialized_) {
......@@ -91,7 +91,7 @@ public:
// Store the current status, so we can recover it upon popSource
include_info_.push_back(IncludeInfo(active_origin_, last_name_));
include_info_.push_back(IncludeInfo(current_origin, last_name_));
initialized_ = true;
previous_name_ = false;
......@@ -182,9 +182,18 @@ private:
// There optionally can be an origin, that applies before the include.
// We need to save the currently active origin before calling
// doOrigin(), because it would update active_origin_ while we need
// to pass the active origin before recognizing the new origin to
// pushSource. Note: RFC 1035 is not really clear on this: it reads
// "regardless of changes... within the included file", but the new
// origin is not really specified "within the included file".
// Nevertheless, this behavior is probably more likely to be the
// intent of the RFC, and it's compatible with BIND 9.
const Name current_origin = active_origin_;
pushSource(filename, current_origin);
// A helper method for loadIncremental(). It parses part of an RR
......@@ -512,7 +521,7 @@ MasterLoader::MasterLoaderImpl::loadIncremental(size_t count_limit) {
"Trying to load when already loaded");
if (!initialized_) {
pushSource(master_file_, active_origin_);
size_t count = 0;
while (ok_ && count < count_limit) {
......@@ -544,7 +544,7 @@ TEST_F(MasterLoaderTest, includeAndOrigin) {
"@ 1H IN A\n"
// Then include the file with data and switch origin back
// Another RR to see the switch survives after we exit include
// Another RR to see we fall back to the previous origin.
"www 1H IN A\n";
stringstream ss(include_string);
setLoader(ss, Name(""), RRClass::IN(),
......@@ -557,7 +557,7 @@ TEST_F(MasterLoaderTest, includeAndOrigin) {
// And check it's the correct data
// Like above, but the origin after include is bogus. The whole line should
......@@ -582,7 +582,8 @@ TEST_F(MasterLoaderTest, includeAndBadOrigin) {
// Check the origin doesn't get outside of the included file.
TEST_F(MasterLoaderTest, includeOriginRestore) {
const string include_string = "$INCLUDE " TEST_DATA_SRCDIR "/origincheck.txt\n"
const string include_string =
"$INCLUDE " TEST_DATA_SRCDIR "/origincheck.txt\n"
"@ 1H IN A\n";
stringstream ss(include_string);
setLoader(ss, Name(""), RRClass::IN(),
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment