diff --git a/CHANGES b/CHANGES index 467f1d0666..6d48917312 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +3154. [bug] Attempting to print an empty rdataset could trigger + an assert. [RT #25452] + 3152. [cleanup] Some versions of gcc and clang failed due to incorrect use of __builtin_expect. [RT #25183] diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index 12b42dd75c..5af3df5cc7 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: masterdump.c,v 1.99.258.7 2011/06/08 23:02:42 each Exp $ */ +/* $Id: masterdump.c,v 1.99.258.8 2011/09/07 19:11:35 each Exp $ */ /*! \file */ @@ -416,12 +416,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; /* @@ -546,7 +545,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 75200deb51..670e01aa0b 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.2.2.4 2011/07/08 22:57:25 smann Exp $ */ +/* $Id: master_test.c,v 1.2.2.5 2011/09/07 19:11:35 each Exp $ */ /*! \file */ @@ -27,8 +27,10 @@ #include #include #include +#include #include #include +#include #include #include "dnstest.h" @@ -334,6 +336,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 */ @@ -349,6 +395,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()); }