]> granicus.if.org Git - pdns/commitdiff
Simple fix for the current bugs
authorAki Tuomi <cmouse@cmouse.fi>
Tue, 28 Jan 2014 18:23:55 +0000 (20:23 +0200)
committerAki Tuomi <cmouse@desteem.org>
Mon, 2 Jun 2014 09:43:30 +0000 (12:43 +0300)
pdns/dns.hh
pdns/dnsrecords.cc
pdns/test-zoneparser_tng_cc.cc
pdns/zoneparser-tng.cc

index 2e9d5ef6e1b2e2c867a2ad4d9414357a0ff709d4..0b60ee0763a77c9c10d67e7de96b214781014b25 100644 (file)
@@ -80,7 +80,7 @@ public:
   ~DNSResourceRecord(){};
 
   void setContent(const string& content);
-  string getZoneRepresentation();
+  string getZoneRepresentation() const;
 
   // data
   
index f6df0fad9648201f75381df809351ca0650cc249..f54041923627d062d8053267a12e8ab46a47901a 100644 (file)
@@ -48,17 +48,19 @@ void DNSResourceRecord::setContent(const string &cont) {
   }
 }
 
-string DNSResourceRecord::getZoneRepresentation() {
+string DNSResourceRecord::getZoneRepresentation() const {
   ostringstream ret;
   switch(qtype.getCode()) {
     case QType::SRV:
     case QType::MX:
       ret<<priority;
-      ret<<" "<<content<<".";
+      ret<<" "<<content;
+      if (*(content.rbegin()) != '.') ret<<".";
     break;
     case QType::CNAME:
     case QType::NS:
-      ret<<content<<".";
+      ret<<content;
+      if (*(content.rbegin()) != '.') ret<<".";
     break;
     default:
       ret<<content;
index a62957c1497c47a88acca724f10d90115741bcf2..7c1a35519481a7811481e54cd599e11396412f7f 100644 (file)
@@ -33,7 +33,10 @@ BOOST_AUTO_TEST_CASE(test_tng_record_types) {
     BOOST_CHECK_EQUAL(rr.qname, host);
     BOOST_CHECK_EQUAL(rr.ttl, ttl);
     BOOST_CHECK_EQUAL(rr.qtype.getName(), type);
-    BOOST_CHECK_EQUAL(rr.getZoneRepresentation(), data);
+    if (*(rr.content.rbegin()) != '.' && *(data.rbegin()) == '.') 
+      BOOST_CHECK_EQUAL(rr.content, std::string(data.begin(),data.end()-1));
+    else
+      BOOST_CHECK_EQUAL(rr.content, data);
   } 
 
 }
index 0f58f82e4bf3f9bae6416b249613a2b843512813..c5c03ecff1b079f91ca27e27f8a2d3799f6d7132 100644 (file)
@@ -379,7 +379,8 @@ bool ZoneParserTNG::get(DNSResourceRecord& rr, std::string* comment)
   case QType::MX:
     stringtok(recparts, rr.content);
     if(recparts.size()==2) {
-      recparts[1] = stripDot(toCanonic(d_zonename, recparts[1]));
+      if (recparts[1]!=".")
+        recparts[1] = stripDot(toCanonic(d_zonename, recparts[1]));
       rr.content=recparts[0]+" "+recparts[1];
     }
     break;