]> granicus.if.org Git - pdns/commitdiff
mydnsbackend: fix types pointing at root
authorKees Monshouwer <mind04@monshouwer.org>
Mon, 22 Dec 2014 16:57:05 +0000 (17:57 +0100)
committermind04 <mind04@monshouwer.org>
Mon, 22 Dec 2014 19:36:04 +0000 (20:36 +0100)
modules/mydnsbackend/mydnsbackend.cc

index 579ac97d6eea1e0583910132a0363e2f46693cbb..17dbc4dce75d3a78d6dc901aa61c8333e7cb95a0 100644 (file)
@@ -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;