From 6d1218188747bdeb9f8fddc52a0499a8d9490ff4 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Wed, 2 Dec 2020 14:46:19 +0100 Subject: [PATCH] rec: Untangle the validation/resolving qnames and qtypes --- pdns/syncres.cc | 20 ++++++++++---------- pdns/syncres.hh | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 2a0c357db9..19f562dec3 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -1410,9 +1410,9 @@ bool SyncRes::doCNAMECacheCheck(const DNSName &qname, const QType &qtype, vector vState recordState = getValidationStatus(foundName, false); if (recordState == vState::Secure) { LOG(prefix<& records, const std::vector >& signatures) +vState SyncRes::validateRecordsWithSigs(unsigned int depth, const DNSName& qname, const QType& qtype, const DNSName& name, const QType& type, const std::vector& records, const std::vector >& signatures) { skeyset_t keys; if (!signatures.empty()) { @@ -2696,7 +2696,7 @@ vState SyncRes::validateRecordsWithSigs(unsigned int depth, const DNSName& qname if (!signer.empty() && name.isPartOf(signer)) { if ((qtype == QType::DNSKEY || qtype == QType::DS) && signer == qname) { /* we are already retrieving those keys, sorry */ - if (qtype == QType::DS && !signer.isRoot()) { + if (type == QType::DS && signer == name && !signer.isRoot()) { /* Unless we are getting the DS of the root zone, we should never see a DS (or a denial of a DS) signed by the DS itself, since we should be requesting it from the parent zone. Something is very wrong */ @@ -2720,7 +2720,7 @@ vState SyncRes::validateRecordsWithSigs(unsigned int depth, const DNSName& qname recordcontents.insert(record.d_content); } - LOG(d_prefix<<"Going to validate "<first.type == QType::CNAME)) { LOG(d_prefix<<"Validating non-additional record for "<first.name<first.name, i->second.records, i->second.signatures); + recordState = validateRecordsWithSigs(depth, qname, qtype, i->first.name, QType(i->first.type), i->second.records, i->second.signatures); /* we might have missed a cut (zone cut within the same auth servers), causing the NS query for an Insecure zone to seem Bogus during zone cut determination */ if (qtype == QType::NS && i->second.signatures.empty() && vStateIsBogus(recordState) && haveExactValidationStatus(i->first.name) && getValidationStatus(i->first.name) == vState::Indeterminate) { recordState = vState::Indeterminate; @@ -3157,7 +3157,7 @@ RCode::rcodes_ SyncRes::updateCacheFromRecords(unsigned int depth, LWResult& lwr /* in a non authoritative answer, we only care about the DS record (or lack of) */ if ((i->first.type == QType::DS || i->first.type == QType::NSEC || i->first.type == QType::NSEC3) && i->first.place == DNSResourceRecord::AUTHORITY) { LOG(d_prefix<<"Validating DS record for "<first.name<first.name, i->second.records, i->second.signatures); + recordState = validateRecordsWithSigs(depth, qname, qtype, i->first.name, QType(i->first.type), i->second.records, i->second.signatures); } } diff --git a/pdns/syncres.hh b/pdns/syncres.hh index fbc17f3a1d..8581459b8a 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -846,7 +846,7 @@ private: bool validationEnabled() const; uint32_t computeLowestTTD(const std::vector& records, const std::vector >& signatures, uint32_t signaturesTTL) const; void updateValidationState(vState& state, const vState stateUpdate); - vState validateRecordsWithSigs(unsigned int depth, const DNSName& qname, const QType& qtype, const DNSName& name, const std::vector& records, const std::vector >& signatures); + vState validateRecordsWithSigs(unsigned int depth, const DNSName& qname, const QType& qtype, const DNSName& name, const QType& type, const std::vector& records, const std::vector >& signatures); vState validateDNSKeys(const DNSName& zone, const std::vector& dnskeys, const std::vector >& signatures, unsigned int depth); vState getDNSKeys(const DNSName& signer, skeyset_t& keys, unsigned int depth); dState getDenialValidationState(const NegCache::NegCacheEntry& ne, const vState state, const dState expectedState, bool referralToUnsigned); -- 2.47.2