[9.18] chg: dev: Revert isdelegation() to return boolean value again

Closes #5838

Backport of MR !11792

Merge branch 'backport-5838-cid-645252-control-flow-issues-deadcode-in-validator-9.18' into 'bind-9.18'

See merge request isc-projects/bind9!11803
This commit is contained in:
Matthijs Mekking 2026-04-07 08:26:17 +00:00
commit 83e5e8c4d0

View file

@ -256,9 +256,9 @@ exit_check(dns_validator_t *val) {
}
/*%
* The isdelegation() function is called as part of seeking the DS record.
* Look in the NSEC or NSEC3 record returned from a DS query to see if the
* record has the NS bitmap set. If so, we are at a delegation point.
* The is_insecure_referral() function is called as part of seeking the DS
* record. Look in the NSEC or NSEC3 record returned from a DS query to see if
* the record has the NS bitmap set. If so, we are at a delegation point.
*
* If the response contains NSEC3 records with too high iterations, we cannot
* (or rather we are not going to) validate the insecurity proof. Instead we
@ -266,15 +266,16 @@ exit_check(dns_validator_t *val) {
* the delegation.
*
* Returns:
*\li #ISC_R_SUCCESS the NS bitmap was set in the NSEC or NSEC3 record, or
* the NSEC3 covers the name (in case of opt-out), or
* we cannot validate the insecurity proof and are going
* to treat the message as isnecure.
*\li #ISC_R_NOTFOUND the NS bitmap was not set,
*\li #true the NS bitmap was set in the NSEC or NSEC3 record, or
* the NSEC3 covers the name (in case of opt-out), or
* we cannot validate the insecurity proof and are going
* to treat the message as insecure.
*\li #false the NS bitmap was not set.
*/
static isc_result_t
isdelegation(dns_validator_t *val, dns_name_t *name, dns_rdataset_t *rdataset,
isc_result_t dbresult, const char *caller) {
static bool
is_insecure_referral(dns_validator_t *val, dns_name_t *name,
dns_rdataset_t *rdataset, isc_result_t dbresult,
const char *caller) {
dns_fixedname_t fixed;
dns_label_t hashlabel;
dns_name_t nsec3name;
@ -302,7 +303,7 @@ isdelegation(dns_validator_t *val, dns_name_t *name, dns_rdataset_t *rdataset,
goto trynsec3;
}
if (result != ISC_R_SUCCESS) {
return ISC_R_NOTFOUND;
return false;
}
}
@ -316,7 +317,7 @@ isdelegation(dns_validator_t *val, dns_name_t *name, dns_rdataset_t *rdataset,
dns_rdata_reset(&rdata);
}
dns_rdataset_disassociate(&set);
return found ? ISC_R_SUCCESS : ISC_R_NOTFOUND;
return found;
trynsec3:
/*
@ -365,7 +366,7 @@ trynsec3:
"%s: too many iterations",
caller);
dns_rdataset_disassociate(&set);
return ISC_R_SUCCESS;
return true;
}
length = isc_iterated_hash(
hash, nsec3.hash, nsec3.iterations, nsec3.salt,
@ -378,7 +379,7 @@ trynsec3:
found = dns_nsec3_typepresent(&rdata,
dns_rdatatype_ns);
dns_rdataset_disassociate(&set);
return found ? ISC_R_SUCCESS : ISC_R_NOTFOUND;
return found;
}
if ((nsec3.flags & DNS_NSEC3FLAG_OPTOUT) == 0) {
continue;
@ -394,12 +395,12 @@ trynsec3:
memcmp(hash, nsec3.next, length) < 0)))
{
dns_rdataset_disassociate(&set);
return ISC_R_SUCCESS;
return true;
}
}
dns_rdataset_disassociate(&set);
}
return found ? ISC_R_SUCCESS : ISC_R_NOTFOUND;
return found;
}
/*%
@ -615,9 +616,9 @@ fetch_callback_ds(isc_task_t *task, isc_event_t *event) {
} else if (eresult == DNS_R_SERVFAIL) {
goto unexpected;
} else if (eresult != DNS_R_CNAME &&
isdelegation(val, devent->foundname, &val->frdataset,
eresult,
"fetch_callback_ds") == ISC_R_SUCCESS)
is_insecure_referral(val, devent->foundname,
&val->frdataset, eresult,
"fetch_callback_ds"))
{
/*
* Failed to find a DS while trying to prove
@ -785,9 +786,9 @@ validator_callback_ds(isc_task_t *task, isc_event_t *event) {
if ((val->attributes & VALATTR_INSECURITY) != 0 &&
val->frdataset.covers == dns_rdatatype_ds &&
NEGATIVE(&val->frdataset) &&
isdelegation(val, name, &val->frdataset,
DNS_R_NCACHENXRRSET,
"validator_callback_ds") == ISC_R_SUCCESS)
is_insecure_referral(val, name, &val->frdataset,
DNS_R_NCACHENXRRSET,
"validator_callback_ds"))
{
result = markanswer(val, "validator_callback_ds",
"no DS and this is a delegation");
@ -2879,9 +2880,9 @@ seek_ds(dns_validator_t *val, isc_result_t *resp) {
return ISC_R_COMPLETE;
}
result = isdelegation(val, tname, &val->frdataset, result,
"seek_ds");
if (result == ISC_R_SUCCESS) {
if (is_insecure_referral(val, tname, &val->frdataset, result,
"seek_ds"))
{
*resp = markanswer(val, "seek_ds (3)",
"this is a delegation");
return ISC_R_COMPLETE;