]> granicus.if.org Git - pdns/commitdiff
remove some unaligned memory accesses in recursor packet cache
authorBert Hubert <bert.hubert@netherlabs.nl>
Sun, 3 Apr 2011 15:22:26 +0000 (15:22 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sun, 3 Apr 2011 15:22:26 +0000 (15:22 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2122 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/recpacketcache.cc

index 4c80435c39de0c0d84ddccb0466786fea477f915..2a6c497622224cceeb82dbf16a171e49efb71cb1 100644 (file)
@@ -28,9 +28,10 @@ bool RecursorPacketCache::getResponsePacket(const std::string& queryPacket, time
   if((uint32_t)now < iter->d_ttd) { // it is fresh!
 //    cerr<<"Fresh for another "<<iter->d_ttd - now<<" seconds!"<<endl;
     *age = now - iter->d_creation;
-    uint16_t id = ((struct dnsheader*)queryPacket.c_str())->id;
+    uint16_t id;
+    memcpy(&id, queryPacket.c_str(), 2); 
     *responsePacket = iter->d_packet;
-    ((struct dnsheader*)responsePacket->c_str())->id=id;
+    responsePacket->replace(0, 2, (char*)&id, 2);
     d_hits++;
     moveCacheItemToBack(d_packetCache, iter);