Add dns_nsec_requiredtypespresent
checks an NSEC rdataset to ensure that both NSEC and RRSIG are present in the type map. These types are required for the NSEC to be valid
This commit is contained in:
committed by
Petr Špaček
parent
571f3af6e8
commit
8ff2c133b5
@@ -106,4 +106,14 @@ dns_nsec_noexistnodata(dns_rdatatype_t type, const dns_name_t *name,
|
||||
* Return ISC_R_IGNORE when the NSEC is not the appropriate one.
|
||||
*/
|
||||
|
||||
bool
|
||||
dns_nsec_requiredtypespresent(dns_rdataset_t *rdataset);
|
||||
/*
|
||||
* Return true if all the NSEC records in rdataset have both
|
||||
* NSEC and RRSIG present.
|
||||
*
|
||||
* Requires:
|
||||
* \li rdataset to be a NSEC rdataset.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
@@ -460,3 +460,32 @@ dns_nsec_noexistnodata(dns_rdatatype_t type, const dns_name_t *name,
|
||||
*exists = false;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
bool
|
||||
dns_nsec_requiredtypespresent(dns_rdataset_t *nsecset) {
|
||||
dns_rdataset_t rdataset;
|
||||
isc_result_t result;
|
||||
bool found = false;
|
||||
|
||||
REQUIRE(DNS_RDATASET_VALID(nsecset));
|
||||
REQUIRE(nsecset->type == dns_rdatatype_nsec);
|
||||
|
||||
dns_rdataset_init(&rdataset);
|
||||
dns_rdataset_clone(nsecset, &rdataset);
|
||||
|
||||
for (result = dns_rdataset_first(&rdataset); result == ISC_R_SUCCESS;
|
||||
result = dns_rdataset_next(&rdataset))
|
||||
{
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
dns_rdataset_current(&rdataset, &rdata);
|
||||
if (!dns_nsec_typepresent(&rdata, dns_rdatatype_nsec) ||
|
||||
!dns_nsec_typepresent(&rdata, dns_rdatatype_rrsig))
|
||||
{
|
||||
dns_rdataset_disassociate(&rdataset);
|
||||
return (false);
|
||||
}
|
||||
found = true;
|
||||
}
|
||||
dns_rdataset_disassociate(&rdataset);
|
||||
return (found);
|
||||
}
|
||||
|
||||
@@ -5572,6 +5572,15 @@ answer_response:
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Don't cache NSEC if missing NSEC or RRSIG types.
|
||||
*/
|
||||
if (rdataset->type == dns_rdatatype_nsec &&
|
||||
!dns_nsec_requiredtypespresent(rdataset))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Don't cache "white lies" but do cache
|
||||
* "black lies".
|
||||
|
||||
Reference in New Issue
Block a user