Commit e5336c30 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2429] warn when no default TTL is available and the TTL of the last RR is used

parent f7470975
......@@ -64,7 +64,8 @@ public:
many_errors_((options & MANY_ERRORS) != 0),
source_count_(0),
complete_(false),
seen_error_(false)
seen_error_(false),
warn_rfc1035_ttl_(true)
{}
void reportError(const std::string& filename, size_t line,
......@@ -234,6 +235,8 @@ public:
bool complete_; // All work done.
bool seen_error_; // Was there at least one error during the
// load?
bool warn_rfc1035_ttl_; // should warn if implicit TTL determination
// from the previous RR is used.
};
bool
......@@ -341,9 +344,14 @@ MasterLoader::MasterLoaderImpl::loadIncremental(size_t count_limit) {
}
} else if (!explicit_ttl && default_ttl_) {
setCurrentTTL(*default_ttl_);
} else if (!explicit_ttl) {
; // warn it
} // else, explicit_ttl, that's used
} else if (!explicit_ttl && warn_rfc1035_ttl_) {
// Omitted (class and) TTL values are default to the last
// explicitly stated values (RFC 1035, Sec. 5.1).
callbacks_.warning(lexer_.getSourceName(),
lexer_.getSourceLine(),
"using RFC1035 TTL semantics");
warn_rfc1035_ttl_ = false; // we only warn about it once
}
add_callback_(name, rrclass, rrtype, *current_ttl_, data);
......
......@@ -426,6 +426,24 @@ TEST_F(MasterLoaderTest, ttlFromSOA) {
"no TTL specified; using SOA MINTTL instead"));
}
TEST_F(MasterLoaderTest, ttlFromPrevious) {
// No available default TTL. 2nd and 3rd RR will use the TTL of the
// 1st RR. This will result in a warning, but only for the first time.
stringstream zone_stream("a.example.org. 1800 IN A 192.0.2.1\n"
"b.example.org. IN A 192.0.2.2\n"
"c.example.org. IN A 192.0.2.3\n");
setLoader(zone_stream, Name("example.org."), RRClass::IN(),
MasterLoader::DEFAULT);
loader_->load();
EXPECT_TRUE(loader_->loadedSucessfully());
checkRR("a.example.org", RRType::A(), "192.0.2.1", RRTTL(1800));
checkRR("b.example.org", RRType::A(), "192.0.2.2", RRTTL(1800));
checkRR("c.example.org", RRType::A(), "192.0.2.3", RRTTL(1800));
EXPECT_EQ(1, warnings_.size());
EXPECT_EQ(0, warnings_.at(0).find("using RFC1035 TTL semantics"));
}
// Test the constructor rejects empty add callback.
TEST_F(MasterLoaderTest, emptyCallback) {
EXPECT_THROW(MasterLoader(TEST_DATA_SRCDIR "/example.org",
......
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