From 8aa5a28cd2376a19dc8c47b88fdafdfb4754f1ec Mon Sep 17 00:00:00 2001 From: Kees Monshouwer Date: Tue, 2 Jun 2015 16:06:51 +0200 Subject: [PATCH] RRSIG wildcard labelcount --- pdns/dnsname.cc | 8 ++++++++ pdns/dnsname.hh | 1 + pdns/dnssecsigner.cc | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pdns/dnsname.cc b/pdns/dnsname.cc index 2c11810fc1..329fa58de4 100644 --- a/pdns/dnsname.cc +++ b/pdns/dnsname.cc @@ -163,6 +163,14 @@ bool DNSName::chopOff() return true; } +bool DNSName::isWildcard() const +{ + if(d_storage.empty()) + return false; + auto p = d_storage.begin(); + return (*p == 0x01 && *++p == '*'); +} + unsigned int DNSName::countLabels() const { unsigned int count=0; diff --git a/pdns/dnsname.hh b/pdns/dnsname.hh index a0e20c1b20..af243d33b5 100644 --- a/pdns/dnsname.hh +++ b/pdns/dnsname.hh @@ -41,6 +41,7 @@ public: void prependRawLabel(const std::string& str); //!< Prepend this unescaped label std::vector getRawLabels() const; //!< Individual raw unescaped labels bool chopOff(); //!< Turn www.powerdns.com. into powerdns.com., returns false for . + bool isWildcard() const; unsigned int countLabels() const; bool empty() const { return countLabels()==0; } // FIXME remove me? void clear() { trimToLabels(0); } // FIXME remove me? diff --git a/pdns/dnssecsigner.cc b/pdns/dnssecsigner.cc index 0a3a0bb0b5..b7eeb352e5 100644 --- a/pdns/dnssecsigner.cc +++ b/pdns/dnssecsigner.cc @@ -44,7 +44,7 @@ int getRRSIGsForRRSET(DNSSECKeeper& dk, const DNSName& signer, const DNSName sig RRSIGRecordContent rrc; rrc.d_type=signQType; - rrc.d_labels=signQName.countLabels(); + rrc.d_labels=signQName.countLabels()-signQName.isWildcard(); rrc.d_originalttl=signTTL; rrc.d_siginception=startOfWeek - 7*86400; // XXX should come from zone metadata rrc.d_sigexpire=startOfWeek + 14*86400; -- 2.47.2