From: Kees Monshouwer Date: Sat, 7 Nov 2015 23:50:42 +0000 (+0100) Subject: various DNSName() fixes X-Git-Tag: dnsdist-1.0.0-alpha1~239^2~1^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=07338ade2204f1eb26b1f3a76fd8e82903742ba3;p=pdns various DNSName() fixes --- 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;