]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Do not call exit() upon is_empty() errors
authorMichał Kępień <michal@isc.org>
Fri, 15 Jun 2018 07:59:20 +0000 (09:59 +0200)
committerMichał Kępień <michal@isc.org>
Fri, 15 Jun 2018 08:35:49 +0000 (10:35 +0200)
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.

lib/dns/zoneverify.c

index 0c0dbe7e574689d61d1240d6f71d7f069f9bbf46..3627f38a8001c0ebd5db8b8780fd93039f1e2559 100644 (file)
@@ -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) {