From: Michał Kępień Date: Fri, 15 Jun 2018 07:59:20 +0000 (+0200) Subject: Do not call exit() upon is_empty() errors X-Git-Tag: v9.13.2~31^2~16 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=7a996f0c0de9fd3f2ba2ad0983a0773cc2a5764b;p=thirdparty%2Fbind9.git Do not call exit() upon is_empty() errors Replace the check_result() call inside is_empty() with a zoneverify_log_error() call and error handling code. Enable is_empty() to signal errors to the caller using its return value. Modify the call site of is_empty() so that its errors are properly handled. --- diff --git a/lib/dns/zoneverify.c b/lib/dns/zoneverify.c index 0c0dbe7e574..3627f38a800 100644 --- a/lib/dns/zoneverify.c +++ b/lib/dns/zoneverify.c @@ -862,18 +862,23 @@ verifynode(vctx_t *vctx, dns_name_t *name, dns_dbnode_t *node, return (result); } -static isc_boolean_t -is_empty(const vctx_t *vctx, dns_dbnode_t *node) { +static isc_result_t +is_empty(const vctx_t *vctx, dns_dbnode_t *node, isc_boolean_t *empty) { dns_rdatasetiter_t *rdsiter = NULL; isc_result_t result; result = dns_db_allrdatasets(vctx->db, node, vctx->ver, 0, &rdsiter); - check_result(result, "dns_db_allrdatasets()"); + if (result != ISC_R_SUCCESS) { + zoneverify_log_error(vctx, "dns_db_allrdatasets(): %s", + isc_result_totext(result)); + return (result); + } result = dns_rdatasetiter_first(rdsiter); dns_rdatasetiter_destroy(&rdsiter); - if (result == ISC_R_NOMORE) - return (ISC_TRUE); - return (ISC_FALSE); + + *empty = ISC_TF(result == ISC_R_NOMORE); + + return (ISC_R_SUCCESS); } static isc_result_t @@ -1494,6 +1499,7 @@ verify_nodes(vctx_t *vctx, isc_result_t *vresult) { nextnode = NULL; result = dns_dbiterator_next(dbiter); while (result == ISC_R_SUCCESS) { + isc_boolean_t empty; result = dns_dbiterator_current(dbiter, &nextnode, nextname); if (result != ISC_R_SUCCESS && @@ -1521,12 +1527,16 @@ verify_nodes(vctx_t *vctx, isc_result_t *vresult) { result = dns_dbiterator_next(dbiter); continue; } - if (is_empty(vctx, nextnode)) { - dns_db_detachnode(vctx->db, &nextnode); + result = is_empty(vctx, nextnode, &empty); + dns_db_detachnode(vctx->db, &nextnode); + if (result != ISC_R_SUCCESS) { + dns_db_detachnode(vctx->db, &node); + goto done; + } + if (empty) { result = dns_dbiterator_next(dbiter); continue; } - dns_db_detachnode(vctx->db, &nextnode); break; } if (result == ISC_R_NOMORE) {