]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
DNS_R_NEWORIGIN could be accidently returned, clearnode's result was being ignored
authorMark Andrews <marka@isc.org>
Fri, 26 Aug 2011 05:12:56 +0000 (05:12 +0000)
committerMark Andrews <marka@isc.org>
Fri, 26 Aug 2011 05:12:56 +0000 (05:12 +0000)
lib/dns/cache.c

index a13a4aee52e5d28edebff84e8858c86136b7c6c1..7ba944b7bc133a3803421cdfa029e313c2092332 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: cache.c,v 1.90 2011/08/02 20:36:12 each Exp $ */
+/* $Id: cache.c,v 1.91 2011/08/26 05:12:56 marka Exp $ */
 
 /*! \file */
 
@@ -1186,7 +1186,7 @@ clearnode(dns_db_t *db, dns_dbnode_t *node) {
 
 static isc_result_t
 cleartree(dns_db_t *db, dns_name_t *name) {
-       isc_result_t result;
+       isc_result_t result, answer = ISC_R_SUCCESS;
        dns_dbiterator_t *iter = NULL;
        dns_dbnode_t *node = NULL;
        dns_fixedname_t fnodename;
@@ -1205,12 +1205,22 @@ cleartree(dns_db_t *db, dns_name_t *name) {
 
        while (result == ISC_R_SUCCESS) {
                result = dns_dbiterator_current(iter, &node, nodename);
-               if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN)
+               if (result == DNS_R_NEWORIGIN)
+                       result = ISC_R_SUCCESS;
+               if (result != ISC_R_SUCCESS)
                        goto cleanup;
+               /*
+                * Are we done?
+                */
                if (! dns_name_issubdomain(nodename, name))
                        goto cleanup;
 
+               /*
+                * If clearnode fails record and move onto the next node.
+                */
                result = clearnode(db, node);
+               if (result != ISC_R_SUCCESS && answer == ISC_R_SUCCESS)
+                       answer = result;
                dns_db_detachnode(db, &node);
                result = dns_dbiterator_next(iter);
        }
@@ -1218,12 +1228,14 @@ cleartree(dns_db_t *db, dns_name_t *name) {
  cleanup:
        if (result == ISC_R_NOMORE || result == ISC_R_NOTFOUND)
                result = ISC_R_SUCCESS;
+       if (result != ISC_R_SUCCESS && answer == ISC_R_SUCCESS)
+               answer = result;
        if (node != NULL)
                dns_db_detachnode(db, &node);
        if (iter != NULL)
                dns_dbiterator_destroy(&iter);
 
-       return (result);
+       return (answer);
 }
 
 isc_result_t