]> granicus.if.org Git - pdns/commitdiff
fix TXT record serving + improve error messages creating packets
authorBert Hubert <bert.hubert@netherlabs.nl>
Wed, 21 Mar 2007 20:21:12 +0000 (20:21 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Wed, 21 Mar 2007 20:21:12 +0000 (20:21 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@985 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/dnspacket.cc

index 30c01c07fc7e9b8e8cfd5b18bc77df5225009ee2..f26d25acba699a0802943971d26fecc03810ac41 100644 (file)
@@ -317,20 +317,23 @@ void DNSPacket::wrapup(void)
   pw.getHeader()->rd=d.rd;
 
   if(!rrs.empty()) {
-    for(pos=rrs.begin();pos<rrs.end();++pos) {
-      // this needs to deal with the 'prio' mismatch!
-      if(pos->qtype.getCode()==QType::MX || pos->qtype.getCode() == QType::SRV) {  
-       pos->content = lexical_cast<string>(pos->priority) + " " + pos->content;
-      }
-      pw.startRecord(pos->qname, pos->qtype.getCode(), pos->ttl, 1, (DNSPacketWriter::Place)pos->d_place); 
-      shared_ptr<DNSRecordContent> drc(DNSRecordContent::mastermake(pos->qtype.getCode(), 1, pos->content)); 
-      drc->toPacket(pw);
-    }
     try {
+      for(pos=rrs.begin();pos<rrs.end();++pos) {
+       // this needs to deal with the 'prio' mismatch!
+       if(pos->qtype.getCode()==QType::MX || pos->qtype.getCode() == QType::SRV) {  
+         pos->content = lexical_cast<string>(pos->priority) + " " + pos->content;
+       }
+       pw.startRecord(pos->qname, pos->qtype.getCode(), pos->ttl, 1, (DNSPacketWriter::Place)pos->d_place); 
+       if(!pos->content.empty() && pos->content[0]!='"') {
+         pos->content="\""+pos->content+"\"";
+       }
+       shared_ptr<DNSRecordContent> drc(DNSRecordContent::mastermake(pos->qtype.getCode(), 1, pos->content)); 
+       drc->toPacket(pw);
+      }
       pw.commit();
     }
     catch(exception& e) {
-      cerr<<"Exception: "<<e.what()<<endl;
+      L<<Logger::Error<<"Exception: "<<e.what()<<endl;
       throw;
     }
   }