2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

fix: dev: Fix a logic error in cache_name()

A change in 6aba56ae8 (checking whether a rejected RRset was identical
to the data it would have replaced, so that we could still cache a
signature) inadvertently introduced cases where processing of a
response would continue when previously it would have been skipped.

Closes #5197

Merge branch '5197-cache_name-logic-error' into 'main'

See merge request isc-projects/bind9!10157
This commit is contained in:
Evan Hunt
2025-02-24 23:39:23 +00:00

View File

@@ -6103,7 +6103,8 @@ cache_name(fetchctx_t *fctx, dns_name_t *name, dns_message_t *message,
if (result == DNS_R_UNCHANGED) { if (result == DNS_R_UNCHANGED) {
result = ISC_R_SUCCESS; result = ISC_R_SUCCESS;
if (!need_validation && if (!need_validation &&
ardataset != NULL) ardataset != NULL &&
NEGATIVE(ardataset))
{ {
/* /*
* The answer in the * The answer in the
@@ -6117,12 +6118,17 @@ cache_name(fetchctx_t *fctx, dns_name_t *name, dns_message_t *message,
if (NXDOMAIN(ardataset)) { if (NXDOMAIN(ardataset)) {
eresult = eresult =
DNS_R_NCACHENXDOMAIN; DNS_R_NCACHENXDOMAIN;
} else if (NEGATIVE(ardataset)) } else {
{
eresult = eresult =
DNS_R_NCACHENXRRSET; DNS_R_NCACHENXRRSET;
} }
continue;
} else if (!need_validation &&
ardataset != NULL &&
sigrdataset != NULL &&
!dns_rdataset_equals(
rdataset, ardataset))
{
/* /*
* The cache wasn't updated * The cache wasn't updated
* because something was * because something was
@@ -6130,16 +6136,11 @@ cache_name(fetchctx_t *fctx, dns_name_t *name, dns_message_t *message,
* data was the same as what * data was the same as what
* we were trying to add, * we were trying to add,
* then sigrdataset might * then sigrdataset might
* still be useful. If * still be useful, and we
* not, move on. * should carry on caching
* it. Otherwise, move on.
*/ */
if (sigrdataset != NULL && continue;
!dns_rdataset_equals(
rdataset,
addedrdataset))
{
continue;
}
} }
} }
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {