From 07338ade2204f1eb26b1f3a76fd8e82903742ba3 Mon Sep 17 00:00:00 2001 From: Kees Monshouwer Date: Sun, 8 Nov 2015 00:50:42 +0100 Subject: [PATCH] various DNSName() fixes --- pdns/backends/gsql/gsqlbackend.cc | 1 - pdns/dnsname.cc | 9 +++++---- pdns/dnssecsigner.cc | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pdns/backends/gsql/gsqlbackend.cc b/pdns/backends/gsql/gsqlbackend.cc index 422275a60..ead7aff35 100644 --- a/pdns/backends/gsql/gsqlbackend.cc +++ b/pdns/backends/gsql/gsqlbackend.cc @@ -1588,7 +1588,6 @@ void GSQLBackend::extractRecord(const SSqlStatement::row_t& row, DNSResourceReco r.qname=d_qname; else r.qname=DNSName(row[6]); - if (r.qname.empty()) r.qname = DNSName("."); r.qtype=row[3]; diff --git a/pdns/dnsname.cc b/pdns/dnsname.cc index 464eec5ce..7f7976e91 100644 --- a/pdns/dnsname.cc +++ b/pdns/dnsname.cc @@ -86,12 +86,13 @@ std::string DNSName::toString(const std::string& separator, const bool trailing) throw std::out_of_range("Attempt to print an unset dnsname"); } + if(isRoot()) + return trailing ? separator : ""; + std::string ret; for(const auto& s : getRawLabels()) { ret+= escapeLabel(s) + separator; } - if(ret.empty()) - return trailing ? separator : ""; return ret.substr(0, ret.size()-!trailing); } @@ -142,7 +143,7 @@ DNSName DNSName::makeRelative(const DNSName& zone) const { DNSName ret(*this); ret.makeUsRelative(zone); - return ret; + return ret.empty() ? zone : ret; // HACK FIXME400 } void DNSName::makeUsRelative(const DNSName& zone) { @@ -232,7 +233,7 @@ bool DNSName::chopOff() bool DNSName::isWildcard() const { - if(d_storage.empty()) + if(d_storage.size() < 2) return false; auto p = d_storage.begin(); return (*p == 0x01 && *++p == '*'); diff --git a/pdns/dnssecsigner.cc b/pdns/dnssecsigner.cc index f8c22327a..52beb9370 100644 --- a/pdns/dnssecsigner.cc +++ b/pdns/dnssecsigner.cc @@ -225,6 +225,8 @@ void addRRSigs(DNSSECKeeper& dk, UeberBackend& db, const set& authSet, signQName= DNSName(toLower(pos->qname.toString())); if(!pos->wildcardname.empty()) wildcardQName = DNSName(toLower(pos->wildcardname.toString())); + else + wildcardQName.clear(); signQType = pos ->qtype.getCode(); if(pos->signttl) signTTL = pos->signttl; -- 2.40.0