Skip to content

Commit

Permalink
rec: fix the zoneToCache regression introduced by SA 2024-01
Browse files Browse the repository at this point in the history
Test will follow
  • Loading branch information
omoerbeek committed Feb 14, 2024
1 parent 22f5278 commit c7f594e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions pdns/recursordist/rec-zonetocache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ vState ZoneData::dnssecValidate(pdns::ZoneMD& zonemd, size_t& zonemdCount) const
}

skeyset_t validKeys;
vState dnsKeyState = validateDNSKeysAgainstDS(d_now, d_zone, dsmap, dnsKeys, records, zonemd.getRRSIGs(), validKeys, std::nullopt, validationContext);
vState dnsKeyState = validateDNSKeysAgainstDS(d_now, d_zone, dsmap, dnsKeys, records, zonemd.getRRSIGs(QType::DNSKEY), validKeys, std::nullopt, validationContext);
if (dnsKeyState != vState::Secure) {
return dnsKeyState;
}
Expand Down Expand Up @@ -306,7 +306,7 @@ vState ZoneData::dnssecValidate(pdns::ZoneMD& zonemd, size_t& zonemdCount) const
for (const auto& rec : zonemd.getNSEC3Params()) {
records.emplace(rec);
}
nsecValidationStatus = validateWithKeySet(d_now, d_zone, records, zonemd.getRRSIGs(), validKeys, std::nullopt, validationContext);
nsecValidationStatus = validateWithKeySet(d_now, d_zone, records, zonemd.getRRSIGs(QType::NSEC3PARAM), validKeys, std::nullopt, validationContext);
if (nsecValidationStatus != vState::Secure) {
d_log->info(Logr::Warning, "NSEC3PARAMS records did not validate");
return nsecValidationStatus;
Expand Down Expand Up @@ -339,7 +339,7 @@ vState ZoneData::dnssecValidate(pdns::ZoneMD& zonemd, size_t& zonemdCount) const
for (const auto& rec : zonemdRecords) {
records.emplace(rec);
}
return validateWithKeySet(d_now, d_zone, records, zonemd.getRRSIGs(), validKeys, std::nullopt, validationContext);
return validateWithKeySet(d_now, d_zone, records, zonemd.getRRSIGs(QType::ZONEMD), validKeys, std::nullopt, validationContext);
}

void ZoneData::ZoneToCache(const RecZoneToCache::Config& config)
Expand Down
2 changes: 1 addition & 1 deletion pdns/zonemd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void pdns::ZoneMD::processRecord(const DNSRecord& record)
if (rrsig == nullptr) {
throw PDNSException("Invalid RRSIG record");
}
d_rrsigs.emplace_back(rrsig);
d_rrsigs[rrsig->d_type].emplace_back(rrsig);
if (rrsig->d_type == QType::NSEC) {
d_nsecs.signatures.emplace_back(rrsig);
}
Expand Down
9 changes: 6 additions & 3 deletions pdns/zonemd.hh
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ public:
}

// Return the zone's apex RRSIGs
[[nodiscard]] const std::vector<shared_ptr<const RRSIGRecordContent>>& getRRSIGs() const
[[nodiscard]] const std::vector<shared_ptr<const RRSIGRecordContent>>& getRRSIGs(QType requestedType)
{
return d_rrsigs;
if (d_rrsigs.count(requestedType) == 0) {
d_rrsigs[requestedType] = {};
}
return d_rrsigs[requestedType];
}

// Return the zone's apex ZONEMDs
Expand Down Expand Up @@ -140,7 +143,7 @@ private:

std::shared_ptr<const SOARecordContent> d_soaRecordContent;
std::set<shared_ptr<const DNSKEYRecordContent>> d_dnskeys;
std::vector<shared_ptr<const RRSIGRecordContent>> d_rrsigs;
std::map<QType, std::vector<shared_ptr<const RRSIGRecordContent>>> d_rrsigs;
std::vector<shared_ptr<const NSEC3PARAMRecordContent>> d_nsec3params;
ContentSigPair d_nsecs;
map<DNSName, ContentSigPair> d_nsec3s;
Expand Down

0 comments on commit c7f594e

Please sign in to comment.