2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-04 08:35:31 +00:00

DNS_R_NEWORIGIN could be accidently returned, clearnode's result was being ignored

This commit is contained in:
Mark Andrews
2011-08-26 05:12:56 +00:00
parent e1d7ec063f
commit e1cf6fd20a

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE. * 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 */ /*! \file */
@@ -1186,7 +1186,7 @@ clearnode(dns_db_t *db, dns_dbnode_t *node) {
static isc_result_t static isc_result_t
cleartree(dns_db_t *db, dns_name_t *name) { 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_dbiterator_t *iter = NULL;
dns_dbnode_t *node = NULL; dns_dbnode_t *node = NULL;
dns_fixedname_t fnodename; dns_fixedname_t fnodename;
@@ -1205,12 +1205,22 @@ cleartree(dns_db_t *db, dns_name_t *name) {
while (result == ISC_R_SUCCESS) { while (result == ISC_R_SUCCESS) {
result = dns_dbiterator_current(iter, &node, nodename); 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; goto cleanup;
/*
* Are we done?
*/
if (! dns_name_issubdomain(nodename, name)) if (! dns_name_issubdomain(nodename, name))
goto cleanup; goto cleanup;
/*
* If clearnode fails record and move onto the next node.
*/
result = clearnode(db, node); result = clearnode(db, node);
if (result != ISC_R_SUCCESS && answer == ISC_R_SUCCESS)
answer = result;
dns_db_detachnode(db, &node); dns_db_detachnode(db, &node);
result = dns_dbiterator_next(iter); result = dns_dbiterator_next(iter);
} }
@@ -1218,12 +1228,14 @@ cleartree(dns_db_t *db, dns_name_t *name) {
cleanup: cleanup:
if (result == ISC_R_NOMORE || result == ISC_R_NOTFOUND) if (result == ISC_R_NOMORE || result == ISC_R_NOTFOUND)
result = ISC_R_SUCCESS; result = ISC_R_SUCCESS;
if (result != ISC_R_SUCCESS && answer == ISC_R_SUCCESS)
answer = result;
if (node != NULL) if (node != NULL)
dns_db_detachnode(db, &node); dns_db_detachnode(db, &node);
if (iter != NULL) if (iter != NULL)
dns_dbiterator_destroy(&iter); dns_dbiterator_destroy(&iter);
return (result); return (answer);
} }
isc_result_t isc_result_t