]> granicus.if.org Git - pdns/commitdiff
no label compression for name in TSIG records
authorKees Monshouwer <mind04@monshouwer.org>
Sat, 20 Jul 2013 14:05:11 +0000 (16:05 +0200)
committermind04 <mind04@monshouwer.org>
Thu, 21 Nov 2013 21:32:09 +0000 (22:32 +0100)
pdns/dnssecinfra.cc
pdns/dnswriter.cc
pdns/dnswriter.hh

index 0b2ed39cca3bd73ea5d60bb316d6cbbcd6a2e8fb..c4cf85c8090df2a8f10e6330aa662f9986dd7229 100644 (file)
@@ -529,7 +529,7 @@ void addTSIG(DNSPacketWriter& pw, TSIGRecordContent* trc, const string& tsigkeyn
 
   trc->d_mac = calculateMD5HMAC(tsigsecret, toSign);
   //  d_trc->d_mac[0]++; // sabotage
-  pw.startRecord(tsigkeyname, QType::TSIG, 0, 0xff, DNSPacketWriter::ADDITIONAL); 
+  pw.startRecord(tsigkeyname, QType::TSIG, 0, 0xff, DNSPacketWriter::ADDITIONAL, false);
   trc->toPacket(pw);
   pw.commit();
 }
index b39fa1ca4a91c2e9822a405400b0353ca306d034..cd30f37f2b2fcc34dc6dfea81f4b51fee8057efd 100644 (file)
@@ -53,7 +53,7 @@ dnsheader* DNSPacketWriter::getHeader()
   return (dnsheader*)&*d_content.begin();
 }
 
-void DNSPacketWriter::startRecord(const string& name, uint16_t qtype, uint32_t ttl, uint16_t qclass, Place place)
+void DNSPacketWriter::startRecord(const string& name, uint16_t qtype, uint32_t ttl, uint16_t qclass, Place place, bool compress)
 {
   if(!d_record.empty()) 
     commit();
@@ -64,19 +64,19 @@ void DNSPacketWriter::startRecord(const string& name, uint16_t qtype, uint32_t t
   d_recordttl=ttl;
   d_recordplace=place;
 
-  d_stuff = 0; 
+  d_stuff = 0;
   d_rollbackmarker=d_content.size();
 
-  if(pdns_iequals(d_qname, d_recordqname)) {  // don't do the whole label compression thing if we *know* we can get away with "see question"
+  if(compress && pdns_iequals(d_qname, d_recordqname)) {  // don't do the whole label compression thing if we *know* we can get away with "see question"
     static unsigned char marker[2]={0xc0, 0x0c};
     d_content.insert(d_content.end(), (const char *) &marker[0], (const char *) &marker[2]);
   }
   else {
-    xfrLabel(d_recordqname, true);
+    xfrLabel(d_recordqname, compress);
     d_content.insert(d_content.end(), d_record.begin(), d_record.end());
     d_record.clear();
   }
-      
+
   d_stuff = sizeof(dnsrecordheader); // this is needed to get compressed label offsets right, the dnsrecordheader will be interspersed
   d_sor=d_content.size() + d_stuff; // start of real record 
 }
index 69bd88e5385b4702487c83c5357346e7547c8e14..6bed390c3a4eaf9210f4c2a89e555e7f9e8c81b4 100644 (file)
@@ -50,7 +50,7 @@ public:
   
   /** Start a new DNS record within this packet for namq, qtype, ttl, class and in the requested place. Note that packets can only be written in natural order - 
       ANSWER, AUTHORITY, ADDITIONAL */
-  void startRecord(const string& name, uint16_t qtype, uint32_t ttl=3600, uint16_t qclass=1, Place place=ANSWER);
+  void startRecord(const string& name, uint16_t qtype, uint32_t ttl=3600, uint16_t qclass=1, Place place=ANSWER, bool compress=true);
 
   /** Shorthand way to add an Opt-record, for example for EDNS0 purposes */
   typedef vector<pair<uint16_t,std::string> > optvect_t;