]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
don't mess up encoding when copying qname from question to answer in packetcache...
authorPeter van Dijk <peter.van.dijk@netherlabs.nl>
Fri, 12 Apr 2013 11:18:04 +0000 (11:18 +0000)
committerPeter van Dijk <peter.van.dijk@netherlabs.nl>
Fri, 12 Apr 2013 11:18:04 +0000 (11:18 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@3155 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/dnspacket.cc
pdns/dnspacket.hh
pdns/packetcache.cc

index 70ea974c73bc306ab79f3def28ebf068b4d653ea..e38edd72f4d1301414c056cccc5c3f48c222fc9c 100644 (file)
@@ -393,18 +393,20 @@ DNSPacket *DNSPacket::replyPacket() const
   return r;
 }
 
-void DNSPacket::spoofQuestion(const string &qd)
+void DNSPacket::spoofQuestion(const DNSPacket *qd)
 {
-  string label=simpleCompress(qd);
   d_wrapped=true; // if we do this, don't later on wrapup
   
-  if(label.size() + sizeof(d) > d_rawpacket.size()) { // probably superfluous
-    return; 
+  int labellen;
+  string::size_type i=sizeof(d);
+
+  for(;;) {
+    labellen = qd->d_rawpacket[i];
+    if(!labellen) break;
+    i++;
+    d_rawpacket.replace(i, labellen, qd->d_rawpacket, i, labellen);
+    i = i + labellen;
   }
-    
-  for(string::size_type i=0; i < label.size(); ++i)
-    d_rawpacket[i+sizeof(d)]=label[i];
-  
 }
 
 int DNSPacket::noparse(const char *mesg, int length)
index b52bd49744cc5a10dbda931741314089374b1948..91c44bddec2258f3735d259321fc17d3098bbbd2 100644 (file)
@@ -123,7 +123,7 @@ public:
 
   DTime d_dt; //!< the time this packet was created. replyPacket() copies this in for you, so d_dt becomes the time spent processing the question+answer
   void wrapup();  // writes out queued rrs, and generates the binary packet. also shuffles. also rectifies dnsheader 'd', and copies it to the stringbuffer
-  void spoofQuestion(const string &qd); //!< paste in the exact right case of the question. Useful for PacketCache
+  void spoofQuestion(const DNSPacket *qd); //!< paste in the exact right case of the question. Useful for PacketCache
   unsigned int getMinTTL(); //!< returns lowest TTL of any record in the packet
 
   vector<DNSResourceRecord*> getAPRecords(); //!< get a vector with DNSResourceRecords that need additional processing
index 75ba26d1b17d23d451c25c5161f731cc943eca24..0acbf725dd60066ed16c5bdc106ba422da611cc9 100644 (file)
@@ -92,7 +92,7 @@ int PacketCache::get(DNSPacket *p, DNSPacket *cached)
     if(cached->noparse(value.c_str(), value.size()) < 0) {
       return 0;
     }
-    cached->spoofQuestion(p->qdomain); // for correct case
+    cached->spoofQuestion(p); // for correct case
     return 1;
   }