From: Remi Gacogne Date: Mon, 9 Jul 2018 14:29:36 +0000 (+0200) Subject: dnsdist: Fix detection of NoData / NXDomain answers in the cache X-Git-Tag: dnsdist-1.3.1~1^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F6782%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Fix detection of NoData / NXDomain answers in the cache Checking whether the SOA record is in the right section was broken because of a misplaced parenthesis, and the unit test checking that case turned out to be broken too (wrong class) :'( The broken check was reported by cppcheck (thanks!): ``` Comparison of a boolean expression with an integer. ``` --- diff --git a/pdns/dnsparser.cc b/pdns/dnsparser.cc index 41806237b9..33fac5f5e2 100644 --- a/pdns/dnsparser.cc +++ b/pdns/dnsparser.cc @@ -809,7 +809,7 @@ uint32_t getDNSPacketMinTTL(const char* packet, size_t length, bool* seenAuthSOA } /* report it if we see a SOA record in the AUTHORITY section */ - if(dnstype == QType::SOA && dnsclass == QClass::IN && seenAuthSOA != nullptr && n >= (ntohs(dh->ancount) && n < (ntohs(dh->ancount) + ntohs(dh->nscount)))) { + if(dnstype == QType::SOA && dnsclass == QClass::IN && seenAuthSOA != nullptr && n >= ntohs(dh->ancount) && n < (ntohs(dh->ancount) + ntohs(dh->nscount))) { *seenAuthSOA = true; } diff --git a/pdns/test-dnsparser_cc.cc b/pdns/test-dnsparser_cc.cc index 4a1084db4f..e9f248cb6b 100644 --- a/pdns/test-dnsparser_cc.cc +++ b/pdns/test-dnsparser_cc.cc @@ -313,7 +313,7 @@ BOOST_AUTO_TEST_CASE(test_getDNSPacketMinTTL) { pwR.getHeader()->qr = 1; pwR.commit(); - pwR.startRecord(name, QType::SOA, 255, QClass::CHAOS, DNSResourceRecord::ADDITIONAL); + pwR.startRecord(name, QType::SOA, 255, QClass::IN, DNSResourceRecord::ADDITIONAL); pwR.commit(); bool seenAuthSOA = false;