diff --git a/CHANGES b/CHANGES index 76af4116e2..20d8932c39 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +3154. [bug] Attempting to print an empty rdataset could trigger + an assert. [RT #25452] + 3153. [func] Extend request-ixfr to zone level and remove the side effect of forcing an AXFR. [RT #25156] diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index 72d938d1cb..e948922034 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: masterdump.c,v 1.108 2011/06/08 22:13:50 each Exp $ */ +/* $Id: masterdump.c,v 1.109 2011/09/07 19:11:13 each Exp $ */ /*! \file */ @@ -419,12 +419,11 @@ rdataset_totext(dns_rdataset_t *rdataset, rdataset->attributes |= DNS_RDATASETATTR_LOADORDER; result = dns_rdataset_first(rdataset); - REQUIRE(result == ISC_R_SUCCESS); current_ttl = ctx->current_ttl; current_ttl_valid = ctx->current_ttl_valid; - do { + while (result == ISC_R_SUCCESS) { column = 0; /* @@ -550,7 +549,7 @@ rdataset_totext(dns_rdataset_t *rdataset, first = ISC_FALSE; result = dns_rdataset_next(rdataset); - } while (result == ISC_R_SUCCESS); + } if (result != ISC_R_NOMORE) return (result); diff --git a/lib/dns/tests/master_test.c b/lib/dns/tests/master_test.c index baee4e1ef1..99c1daa1cb 100644 --- a/lib/dns/tests/master_test.c +++ b/lib/dns/tests/master_test.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: master_test.c,v 1.5 2011/09/02 21:15:37 each Exp $ */ +/* $Id: master_test.c,v 1.6 2011/09/07 19:11:14 each Exp $ */ /*! \file */ @@ -27,8 +27,10 @@ #include #include #include +#include #include #include +#include #include #include "dnstest.h" @@ -326,6 +328,50 @@ ATF_TC_BODY(master_leadingzero, tc) { dns_test_end(); } +ATF_TC(master_totext); +ATF_TC_HEAD(master_totext, tc) { + atf_tc_set_md_var(tc, "descr", "masterfile totext tests"); +} +ATF_TC_BODY(master_totext, tc) { + isc_result_t result; + dns_rdataset_t rdataset; + dns_rdatalist_t rdatalist; + isc_buffer_t target; + unsigned char buf[BIGBUFLEN]; + + UNUSED(tc); + + result = dns_test_begin(NULL, ISC_FALSE); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + /* First, test with an empty rdataset */ + rdatalist.rdclass = dns_rdataclass_in; + rdatalist.type = dns_rdatatype_none; + rdatalist.covers = dns_rdatatype_none; + rdatalist.ttl = 0; + ISC_LIST_INIT(rdatalist.rdata); + ISC_LINK_INIT(&rdatalist, link); + + dns_rdataset_init(&rdataset); + result = dns_rdatalist_tordataset(&rdatalist, &rdataset); + ATF_CHECK_EQ(result, ISC_R_SUCCESS); + + isc_buffer_init(&target, buf, BIGBUFLEN); + result = dns_master_rdatasettotext(dns_rootname, + &rdataset, &dns_master_style_debug, + &target); + ATF_CHECK_EQ(result, ISC_R_SUCCESS); + ATF_CHECK_EQ(isc_buffer_usedlength(&target), 0); + + /* + * XXX: We will also need to add tests for dumping various + * rdata types, classes, etc, and comparing the results against + * known-good output. + */ + + dns_test_end(); +} + /* * Main */ @@ -341,6 +387,7 @@ ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, master_includefail); ATF_TP_ADD_TC(tp, master_blanklines); ATF_TP_ADD_TC(tp, master_leadingzero); + ATF_TP_ADD_TC(tp, master_totext); return (atf_no_error()); }