From: Remi Gacogne Date: Fri, 28 Jul 2017 13:37:33 +0000 (+0200) Subject: We don't need to copy the header in `ageDNSPacket()` X-Git-Tag: rec-4.1.0-rc1~22^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7def3a4b08d6f2c895c586587dcfbfab82244cbe;p=thirdparty%2Fpdns.git We don't need to copy the header in `ageDNSPacket()` --- diff --git a/pdns/dnsparser.cc b/pdns/dnsparser.cc index 5b2faa8f63..52fca0ef13 100644 --- a/pdns/dnsparser.cc +++ b/pdns/dnsparser.cc @@ -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(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);