]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
We don't need to copy the header in `ageDNSPacket()`
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 28 Jul 2017 13:37:33 +0000 (15:37 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 5 Sep 2017 14:52:23 +0000 (16:52 +0200)
pdns/dnsparser.cc

index 5b2faa8f63c054096cfcece4992b94cdecc61eb3..52fca0ef132482be7462fb2572c6edb7a2fbb28b 100644 (file)
@@ -732,13 +732,13 @@ void ageDNSPacket(char* packet, size_t length, uint32_t seconds)
     return;
   try 
   {
-    dnsheader dh;
-    memcpy((void*)&dh, (const dnsheader*)packet, sizeof(dh));
-    uint64_t numrecords = ntohs(dh.ancount) + ntohs(dh.nscount) + ntohs(dh.arcount);
+    const dnsheader* dh = reinterpret_cast<const dnsheader*>(packet);
+    const uint64_t dqcount = ntohs(dh->qdcount);
+    const uint64_t numrecords = ntohs(dh->ancount) + ntohs(dh->nscount) + ntohs(dh->arcount);
     DNSPacketMangler dpm(packet, length);
 
     uint64_t n;
-    for(n=0; n < ntohs(dh.qdcount) ; ++n) {
+    for(n=0; n < dqcount; ++n) {
       dpm.skipLabel();
       /* type and class */
       dpm.skipBytes(4);