]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
spoofID fix - equivalent to t222
authorBert Hubert <bert.hubert@netherlabs.nl>
Sat, 3 Jul 2010 15:15:04 +0000 (15:15 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sat, 3 Jul 2010 15:15:04 +0000 (15:15 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/tags/pdns-2-9-22-x@1663 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/common_startup.cc
pdns/dnspacket.cc
pdns/dnspacket.hh
pdns/dnsproxy.cc
pdns/tcpreceiver.cc

index 909ba4b95ee704fea97fa7616442627227a354cd..7ed7c6301d3e11b5814499f3ddc4fd8ecd810b78 100644 (file)
@@ -251,9 +251,9 @@ void *qthread(void *number)
     if((P->d.opcode != Opcode::Notify) && P->couldBeCached() && PC.get(P, &cached)) { // short circuit - does the PacketCache recognize this question?
       cached.setRemote(&P->remote);  // inlined
       cached.setSocket(P->getSocket());                               // inlined
-      cached.spoofID(P->d.id);                                        // inlined 
       cached.setMaxReplyLen(P->getMaxReplyLen());
       cached.d.rd=P->d.rd; // copy in recursion desired bit 
+      cached.d.id=P->d.id;
       cached.commitD(); // commit d to the packet                        inlined
 
       N->send(&cached);   // answer it then                              inlined
index a0b43dd4cd10daf5622eab9a873068d7f29c7153..1f95e110102851824e7046ca7a47c1310e51beb8 100644 (file)
@@ -514,13 +514,6 @@ void DNSPacket::setRemote(const ComboAddress *s)
   remote=*s;
 }
 
-void DNSPacket::spoofID(uint16_t id)
-{
-  stringbuffer[1]=(id>>8)&0xff; 
-  stringbuffer[0]=id&0xff;
-  d.id=id;
-}
-
 void DNSPacket::setSocket(Utility::sock_t sock)
 {
   d_socket=sock;
index 5fe655aa4ce9ba113b63d208ec81423bdd5707fe..cae7065e835f6b26841125f327fcce93cc23f673 100644 (file)
@@ -129,7 +129,6 @@ public:
   const char *getData(void); //!< get binary representation of packet, will call 'wrapup' for you
 
   const char *getRaw(void); //!< provides access to the raw packet, possibly on a packet that has never been 'wrapped'
-  void spoofID(uint16_t id); //!< change the ID of an existing packet. Useful for fixing up packets returned from the PacketCache
   void spoofQuestion(const string &qd); //!< paste in the exact right case of the question. Useful for PacketCache
   void truncate(int new_length); // has documentation in source
 
index 3a498ad60f0a63290af2185ab4248a380b64460b..d491e39f67b1c1588446c84534ddbd1ab489648c 100644 (file)
@@ -117,8 +117,8 @@ bool DNSProxy::sendPacket(DNSPacket *p)
 
     d_conntrack[id]=ce;
   }
-  p->spoofID(id^d_xor);
-
+  p->d.id=id^d_xor;
+  p->commitD();
   char *buffer=const_cast<char *>(p->getRaw());
   int len=p->len;
   if(send(d_sock,buffer,len,0)<0) { // zoom
index 2bfb22aaf3251ad34746b598a8b57ba70efe3e08..4162b77d6e5f40868a3c11becd7530d563d1f719 100644 (file)
@@ -282,7 +282,10 @@ void *TCPNameserver::doConnection(void *data)
 
       if(!packet->d.rd && (PC.get(packet.get(), cached.get()))) { // short circuit - does the PacketCache recognize this question?
        cached->setRemote(&packet->remote);
-       cached->spoofID(packet->d.id);
+       cached->d.id=packet->d.id;
+       cached->d.rd=packet->d.rd; // copy in recursion desired bit 
+       cached->commitD(); // commit d to the packet                        inlined
+
        sendPacket(cached, fd);
        S.inc("tcp-answers");
        continue;