From: Kees Monshouwer Date: Mon, 22 Dec 2014 16:57:05 +0000 (+0100) Subject: mydnsbackend: fix types pointing at root X-Git-Tag: auth-3.4.2~15^2~31 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d5c9c07ab1decc47a7358bcf7e5becb8c911c2d8;p=pdns mydnsbackend: fix types pointing at root --- diff --git a/modules/mydnsbackend/mydnsbackend.cc b/modules/mydnsbackend/mydnsbackend.cc index 579ac97d6..17dbc4dce 100644 --- a/modules/mydnsbackend/mydnsbackend.cc +++ b/modules/mydnsbackend/mydnsbackend.cc @@ -303,22 +303,22 @@ bool MyDNSBackend::get(DNSResourceRecord &rr) { rr.qname=d_qname; } else { rr.qname=rrow[5]; - if (rr.qname[rr.qname.length()-1] == '.') { + if (!rr.qname.empty() && rr.qname[rr.qname.length()-1] == '.') { rr.qname.erase(rr.qname.length()-1); // Fully qualified, nuke the last . } else { if (!rr.qname.empty()) rr.qname += "."; rr.qname += d_origin; // Not fully qualified } - } - if (rr.qtype.getCode() == QType::NS || rr.qtype.getCode()==QType::MX || - rr.qtype.getCode() == QType::CNAME || rr.qtype.getCode() == QType::PTR) { - if (rr.content[rr.content.length()-1] == '.') { - rr.content.erase(rr.content.length()-1); // Fully qualified, nuke the last . + if (rr.qtype.getCode() == QType::NS || rr.qtype.getCode()==QType::MX || + rr.qtype.getCode() == QType::CNAME || rr.qtype.getCode() == QType::PTR) { + if (!rr.content.empty() && rr.content[rr.content.length()-1] == '.') { + if (rr.content.length() > 1) + rr.content.erase(rr.content.length()-1); // Fully qualified, nuke the last . } else { - if (!rr.content.empty()) + if (rr.content != ".") rr.content += "."; rr.content += d_origin; } @@ -330,7 +330,6 @@ bool MyDNSBackend::get(DNSResourceRecord &rr) { rr.ttl = d_minimum; rr.domain_id=atol(rrow[4].c_str()); - rr.last_modified=0; return true;