From: Remi Gacogne Date: Tue, 17 Nov 2015 09:25:19 +0000 (+0100) Subject: No need to copy the response from the healthcheck, it's not going anywhere X-Git-Tag: dnsdist-1.0.0-alpha1~210^2~10^2~1^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=231d3b6bba63ec5ab626876d904d95089d6bacca;p=pdns No need to copy the response from the healthcheck, it's not going anywhere --- diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index abc24eae6..f1264bd0f 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -575,23 +575,18 @@ try ComboAddress dest=remote; sock.recvFrom(reply, dest); - // dnsparser.cc is not included in dnsdist right now - // MOADNSParser mdp(reply); - // dnsheader const * responseHeader = &mdp.d_header; - struct dnsheader responseHeader; + const dnsheader * responseHeader = (const dnsheader *) reply.c_str(); - if (reply.size() < sizeof(responseHeader)) + if (reply.size() < sizeof(*responseHeader)) return false; - memcpy(&responseHeader, reply.c_str(), sizeof(responseHeader)); - - if (responseHeader.id != requestHeader->id) + if (responseHeader->id != requestHeader->id) return false; - if (!responseHeader.qr) + if (!responseHeader->qr) return false; - if (responseHeader.rcode == RCode::ServFail) + if (responseHeader->rcode == RCode::ServFail) return false; - if (mustResolve && (responseHeader.rcode == RCode::NXDomain || responseHeader.rcode == RCode::Refused)) + if (mustResolve && (responseHeader->rcode == RCode::NXDomain || responseHeader->rcode == RCode::Refused)) return false; // XXX fixme do bunch of checking here etc