From 5d21450eb66c9dd8a56f20bf46eb7daee409a6ac Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Wed, 21 Mar 2018 16:17:54 +0100 Subject: [PATCH] Leave bitshifting Extended RCode to addOpt --- pdns/dnswriter.cc | 2 +- pdns/packethandler.cc | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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; } -- 2.50.1