Skip to content

Commit

Permalink
Improve robustness of root-nx-trust
Browse files Browse the repository at this point in the history
Query names with embedded dots or 00's in labels will no longer make the
recursor (possibly) forget existing TLDs.
  • Loading branch information
pieterlexis committed Apr 20, 2015
1 parent 686b392 commit 9d835ed
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pdns/syncres.cc
Expand Up @@ -681,15 +681,14 @@ bool SyncRes::doCNAMECacheCheck(const string &qname, const QType &qtype, vector<
// accepts . terminated names, www.powerdns.com. -> com. // accepts . terminated names, www.powerdns.com. -> com.
static const string getLastLabel(const std::string& qname) static const string getLastLabel(const std::string& qname)
{ {
if(qname.empty()) if(qname.empty() || qname == ".")
return qname; return qname;
string ret=qname.substr(0, qname.length()-1); // strip .


string::size_type pos = ret.rfind('.'); labelparts_t parts;
if(pos != string::npos) { labeltokUnescape(parts, qname);
ret = ret.substr(pos+1) + "."; int offset = (parts.end()-1)->first;
}
return ret; return qname.substr(offset, qname.size()-offset);
} }


bool SyncRes::doCacheCheck(const string &qname, const QType &qtype, vector<DNSResourceRecord>&ret, int depth, int &res) bool SyncRes::doCacheCheck(const string &qname, const QType &qtype, vector<DNSResourceRecord>&ret, int depth, int &res)
Expand Down

0 comments on commit 9d835ed

Please sign in to comment.