From: Pieter Lexis Date: Wed, 21 Mar 2018 15:17:54 +0000 (+0100) Subject: Leave bitshifting Extended RCode to addOpt X-Git-Tag: dnsdist-1.3.1~50^2~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5d21450eb66c9dd8a56f20bf46eb7daee409a6ac;p=pdns Leave bitshifting Extended RCode to addOpt --- diff --git a/pdns/dnswriter.cc b/pdns/dnswriter.cc index d788217e8..4f7656f60 100644 --- a/pdns/dnswriter.cc +++ b/pdns/dnswriter.cc @@ -110,7 +110,7 @@ void DNSPacketWriter::addOpt(uint16_t udpsize, int extRCode, int Z, const vector * indicates that an unextended RCODE is in use (values 0 through 15). */ stuff.extRCode = extRCode>>4; - if (extRCode != 0) { // As this trumps the existing RCODE + if (extRCode > 15) { // As this trumps the existing RCODE getHeader()->rcode = extRCode; } diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index 9e2ca7e89..415e28343 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -1145,8 +1145,9 @@ DNSPacket *PacketHandler::doQuestion(DNSPacket *p) if (p->hasEDNS() && p->getEDNSVersion() > 0) { r = p->replyPacket(); - r->setRcode(16 & 0xF); - r->setEDNSRcode((16 & 0xFFF0)>>4); // set rcode to BADVERS + + // PacketWriter::addOpt will take care of setting this correctly in the packet + r->setEDNSRcode(ERCode::BADVERS); return r; }