From e1a9ab9fd8d41599cec6f8e99596dcade0597ddd Mon Sep 17 00:00:00 2001 From: bert hubert Date: Fri, 6 Nov 2015 22:01:48 +0100 Subject: [PATCH] fix a few empty DNSName issues --- pdns/dnsname.cc | 5 ++++- pdns/dnssecsigner.cc | 3 ++- pdns/packethandler.cc | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) 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; -- 2.40.0