From: bert hubert Date: Fri, 6 Nov 2015 21:01:48 +0000 (+0100) Subject: fix a few empty DNSName issues X-Git-Tag: dnsdist-1.0.0-alpha1~239^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e1a9ab9fd8d41599cec6f8e99596dcade0597ddd;p=pdns fix a few empty DNSName issues --- diff --git a/pdns/dnsname.cc b/pdns/dnsname.cc index c9488d4bf..ebc8598a3 100644 --- a/pdns/dnsname.cc +++ b/pdns/dnsname.cc @@ -82,8 +82,9 @@ void DNSName::packetParser(const char* qpos, int len, int offset, bool uncompres std::string DNSName::toString(const std::string& separator, const bool trailing) const { - if (empty()) + if (empty()) { throw std::out_of_range("Attempt to print an unset dnsname"); + } std::string ret; for(const auto& s : getRawLabels()) { @@ -156,6 +157,8 @@ void DNSName::makeUsRelative(const DNSName& zone) DNSName DNSName::labelReverse() const { DNSName ret; + if(isRoot()) + return *this; // we don't create the root automatically below if (!empty()) { vector l=getRawLabels(); while(!l.empty()) { diff --git a/pdns/dnssecsigner.cc b/pdns/dnssecsigner.cc index 61db72998..f8c22327a 100644 --- a/pdns/dnssecsigner.cc +++ b/pdns/dnssecsigner.cc @@ -223,7 +223,8 @@ void addRRSigs(DNSSECKeeper& dk, UeberBackend& db, const set& authSet, } signedRecords.push_back(*pos); signQName= DNSName(toLower(pos->qname.toString())); - wildcardQName = DNSName(toLower(pos->wildcardname.toString())); + if(!pos->wildcardname.empty()) + wildcardQName = DNSName(toLower(pos->wildcardname.toString())); signQType = pos ->qtype.getCode(); if(pos->signttl) signTTL = pos->signttl; diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index 2ed23adc2..2449ced08 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -104,6 +104,7 @@ void PacketHandler::addRootReferral(DNSPacket* r) // add . NS records DNSResourceRecord rr; + rr.qname = DNSName("."); rr.qtype=QType::NS; rr.ttl=518400; rr.d_place=DNSResourceRecord::AUTHORITY;