From 4ccbcc8805c0504540593b0f1d23d01ed9fdbeab Mon Sep 17 00:00:00 2001 From: Kees Monshouwer Date: Sun, 16 Feb 2014 20:17:59 +0100 Subject: [PATCH] fix labelcount for root --- pdns/dnssecinfra.cc | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pdns/dnssecinfra.cc b/pdns/dnssecinfra.cc index 85fb5ada98..a8a77fd835 100644 --- a/pdns/dnssecinfra.cc +++ b/pdns/dnssecinfra.cc @@ -305,14 +305,17 @@ DNSKEYRecordContent makeDNSKEYFromDNSCryptoKeyEngine(const DNSCryptoKeyEngine* p int countLabels(const std::string& signQName) { - int count =1; - for(string::const_iterator pos = signQName.begin(); pos != signQName.end() ; ++pos) - if(*pos == '.' && pos+1 != signQName.end()) - count++; - - if(boost::starts_with(signQName, "*.")) - count--; - return count; + if(!signQName.empty()) { + int count=1; + for(string::const_iterator pos = signQName.begin(); pos != signQName.end() ; ++pos) + if(*pos == '.' && pos+1 != signQName.end()) + count++; + + if(boost::starts_with(signQName, "*.")) + count--; + return count; + } + return 0; } uint32_t getStartOfWeek() -- 2.47.2