]> granicus.if.org Git - pdns/commitdiff
dnsdist: Fix detection of NoData / NXDomain answers in the cache
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 9 Jul 2018 14:29:36 +0000 (16:29 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 9 Jul 2018 14:29:36 +0000 (16:29 +0200)
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.
```

pdns/dnsparser.cc
pdns/test-dnsparser_cc.cc

index 41806237b953b9f0fb3a47fb2ab0048979cbdccc..33fac5f5e20916ba35aff38c3838b7d5ed943340 100644 (file)
@@ -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;
       }
 
index 4a1084db4faecc1a7b047aba18bd249db6684e6f..e9f248cb6b318222a647337e94623884725ce20d 100644 (file)
@@ -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;