3445. [bug] Warn about zone files with blank owner names
immediately after $ORIGIN directives. [RT #31848]
This commit is contained in:
@@ -75,7 +75,10 @@ rawdata_callback(dns_zone_t *zone, dns_masterrawheader_t *h) {
|
||||
}
|
||||
|
||||
static int
|
||||
test_master(const char *testfile, dns_masterformat_t format) {
|
||||
test_master(const char *testfile, dns_masterformat_t format,
|
||||
void (*warn)(struct dns_rdatacallbacks *, const char *, ...),
|
||||
void (*error)(struct dns_rdatacallbacks *, const char *, ...))
|
||||
{
|
||||
isc_result_t result;
|
||||
int len;
|
||||
char origin[sizeof(TEST_ORIGIN)];
|
||||
@@ -103,6 +106,10 @@ test_master(const char *testfile, dns_masterformat_t format) {
|
||||
callbacks.add = add_callback;
|
||||
callbacks.rawdata = rawdata_callback;
|
||||
callbacks.zone = NULL;
|
||||
if (warn != NULL)
|
||||
callbacks.warn = warn;
|
||||
if (error != NULL)
|
||||
callbacks.error = error;
|
||||
headerset = ISC_FALSE;
|
||||
result = dns_master_loadfile2(testfile, &dns_origin, &dns_origin,
|
||||
dns_rdataclass_in, ISC_TRUE,
|
||||
@@ -129,7 +136,7 @@ ATF_TC_BODY(load, tc) {
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = test_master("testdata/master/master1.data",
|
||||
dns_masterformat_text);
|
||||
dns_masterformat_text, NULL, NULL);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
dns_test_end();
|
||||
@@ -152,7 +159,7 @@ ATF_TC_BODY(unexpected, tc) {
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = test_master("testdata/master/master2.data",
|
||||
dns_masterformat_text);
|
||||
dns_masterformat_text, NULL, NULL);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_UNEXPECTEDEND);
|
||||
|
||||
dns_test_end();
|
||||
@@ -175,7 +182,7 @@ ATF_TC_BODY(noowner, tc) {
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = test_master("testdata/master/master3.data",
|
||||
dns_masterformat_text);
|
||||
dns_masterformat_text, NULL, NULL);
|
||||
ATF_REQUIRE_EQ(result, DNS_R_NOOWNER);
|
||||
|
||||
dns_test_end();
|
||||
@@ -199,7 +206,7 @@ ATF_TC_BODY(nottl, tc) {
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = test_master("testdata/master/master4.data",
|
||||
dns_masterformat_text);
|
||||
dns_masterformat_text, NULL, NULL);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
dns_test_end();
|
||||
@@ -222,7 +229,7 @@ ATF_TC_BODY(badclass, tc) {
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = test_master("testdata/master/master5.data",
|
||||
dns_masterformat_text);
|
||||
dns_masterformat_text, NULL, NULL);
|
||||
ATF_REQUIRE_EQ(result, DNS_R_BADCLASS);
|
||||
|
||||
dns_test_end();
|
||||
@@ -243,7 +250,7 @@ ATF_TC_BODY(toobig, tc) {
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = test_master("testdata/master/master15.data",
|
||||
dns_masterformat_text);
|
||||
dns_masterformat_text, NULL, NULL);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_NOSPACE);
|
||||
|
||||
dns_test_end();
|
||||
@@ -265,7 +272,7 @@ ATF_TC_BODY(maxrdata, tc) {
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = test_master("testdata/master/master16.data",
|
||||
dns_masterformat_text);
|
||||
dns_masterformat_text, NULL, NULL);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
dns_test_end();
|
||||
@@ -286,7 +293,7 @@ ATF_TC_BODY(dnskey, tc) {
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = test_master("testdata/master/master6.data",
|
||||
dns_masterformat_text);
|
||||
dns_masterformat_text, NULL, NULL);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
dns_test_end();
|
||||
@@ -308,7 +315,7 @@ ATF_TC_BODY(dnsnokey, tc) {
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = test_master("testdata/master/master7.data",
|
||||
dns_masterformat_text);
|
||||
dns_masterformat_text, NULL, NULL);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
dns_test_end();
|
||||
@@ -329,7 +336,7 @@ ATF_TC_BODY(include, tc) {
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = test_master("testdata/master/master8.data",
|
||||
dns_masterformat_text);
|
||||
dns_masterformat_text, NULL, NULL);
|
||||
ATF_REQUIRE_EQ(result, DNS_R_SEENINCLUDE);
|
||||
|
||||
dns_test_end();
|
||||
@@ -350,7 +357,7 @@ ATF_TC_BODY(includefail, tc) {
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = test_master("testdata/master/master9.data",
|
||||
dns_masterformat_text);
|
||||
dns_masterformat_text, NULL, NULL);
|
||||
ATF_REQUIRE_EQ(result, DNS_R_BADCLASS);
|
||||
|
||||
dns_test_end();
|
||||
@@ -372,7 +379,7 @@ ATF_TC_BODY(blanklines, tc) {
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = test_master("testdata/master/master10.data",
|
||||
dns_masterformat_text);
|
||||
dns_masterformat_text, NULL, NULL);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
dns_test_end();
|
||||
@@ -393,7 +400,7 @@ ATF_TC_BODY(leadingzero, tc) {
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = test_master("testdata/master/master11.data",
|
||||
dns_masterformat_text);
|
||||
dns_masterformat_text, NULL, NULL);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
dns_test_end();
|
||||
@@ -459,21 +466,21 @@ ATF_TC_BODY(loadraw, tc) {
|
||||
|
||||
/* Raw format version 0 */
|
||||
result = test_master("testdata/master/master12.data",
|
||||
dns_masterformat_raw);
|
||||
dns_masterformat_raw, NULL, NULL);
|
||||
ATF_CHECK_STREQ(isc_result_totext(result), "success");
|
||||
ATF_CHECK(headerset);
|
||||
ATF_CHECK_EQ(header.flags, 0);
|
||||
|
||||
/* Raw format version 1, no source serial */
|
||||
result = test_master("testdata/master/master13.data",
|
||||
dns_masterformat_raw);
|
||||
dns_masterformat_raw, NULL, NULL);
|
||||
ATF_CHECK_STREQ(isc_result_totext(result), "success");
|
||||
ATF_CHECK(headerset);
|
||||
ATF_CHECK_EQ(header.flags, 0);
|
||||
|
||||
/* Raw format version 1, source serial == 2011120101 */
|
||||
result = test_master("testdata/master/master14.data",
|
||||
dns_masterformat_raw);
|
||||
dns_masterformat_raw, NULL, NULL);
|
||||
ATF_CHECK_STREQ(isc_result_totext(result), "success");
|
||||
ATF_CHECK(headerset);
|
||||
ATF_CHECK((header.flags & DNS_MASTERRAW_SOURCESERIALSET) != 0);
|
||||
@@ -528,7 +535,7 @@ ATF_TC_BODY(dumpraw, tc) {
|
||||
dns_masterformat_raw);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = test_master("test.dump", dns_masterformat_raw);
|
||||
result = test_master("test.dump", dns_masterformat_raw, NULL, NULL);
|
||||
ATF_CHECK_STREQ(isc_result_totext(result), "success");
|
||||
ATF_CHECK(headerset);
|
||||
ATF_CHECK_EQ(header.flags, 0);
|
||||
@@ -543,7 +550,7 @@ ATF_TC_BODY(dumpraw, tc) {
|
||||
dns_masterformat_raw, &header);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
result = test_master("test.dump", dns_masterformat_raw);
|
||||
result = test_master("test.dump", dns_masterformat_raw, NULL, NULL);
|
||||
ATF_CHECK_STREQ(isc_result_totext(result), "success");
|
||||
ATF_CHECK(headerset);
|
||||
ATF_CHECK((header.flags & DNS_MASTERRAW_SOURCESERIALSET) != 0);
|
||||
@@ -555,6 +562,23 @@ ATF_TC_BODY(dumpraw, tc) {
|
||||
dns_test_end();
|
||||
}
|
||||
|
||||
static const char *warn_expect_value;
|
||||
static isc_boolean_t warn_expect_result;
|
||||
|
||||
static void
|
||||
warn_expect(struct dns_rdatacallbacks *callbacks, const char *fmt, ...) {
|
||||
char buf[4096];
|
||||
va_list ap;
|
||||
|
||||
UNUSED(callbacks);
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
va_end(ap);
|
||||
if (warn_expect_value != NULL && strstr(buf, warn_expect_value) != NULL)
|
||||
warn_expect_result = ISC_TRUE;
|
||||
}
|
||||
|
||||
/* Origin change test */
|
||||
ATF_TC(neworigin);
|
||||
ATF_TC_HEAD(neworigin, tc) {
|
||||
@@ -570,9 +594,14 @@ ATF_TC_BODY(neworigin, tc) {
|
||||
result = dns_test_begin(NULL, ISC_FALSE);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
warn_expect_value = "record with inherited owner";
|
||||
warn_expect_result = ISC_FALSE;
|
||||
|
||||
result = test_master("testdata/master/master17.data",
|
||||
dns_masterformat_text);
|
||||
ATF_REQUIRE_EQ(result, DNS_R_UNSAFENAME);
|
||||
dns_masterformat_text, warn_expect, NULL);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
ATF_CHECK_MSG(warn_expect_result, "'%s' warning not emitted",
|
||||
warn_expect_value);
|
||||
|
||||
dns_test_end();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user