]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
correct upper bounds on d_qtypecounters
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 15 Jul 2021 13:47:18 +0000 (15:47 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Mon, 26 Jul 2021 12:58:04 +0000 (14:58 +0200)
pdns/responsestats.cc
pdns/responsestats.hh
regression-tests/tests/type65535-query/command [new file with mode: 0755]
regression-tests/tests/type65535-query/description [new file with mode: 0644]
regression-tests/tests/type65535-query/expected_result [new file with mode: 0644]

index a41add263047972055b3113230561641ce26e3b7..8397e6bab1e6d6eceeb675583994f29aa4499fde 100644 (file)
@@ -27,11 +27,11 @@ static auto sizeBounds()
 ResponseStats::ResponseStats() :
   d_sizecounters("SizeCounters", sizeBounds())
 {
-  for (unsigned int n = 0; n < 65535; ++n) {
-    d_qtypecounters[n].value = 0;
+  for (auto& entry : d_qtypecounters) {
+    entry.value = 0;
   }
-  for (unsigned int n = 0; n < 256; ++n) {
-    d_rcodecounters[n].value = 0;
+  for (auto& entry : d_rcodecounters) {
+    entry.value = 0;
   }
 }
 
@@ -53,7 +53,7 @@ map<uint16_t, uint64_t> ResponseStats::getQTypeResponseCounts() const
 {
   map<uint16_t, uint64_t> ret;
   uint64_t count;
-  for (unsigned int i = 0; i < 65535; ++i) {
+  for (unsigned int i = 0; i < d_qtypecounters.size(); ++i) {
     count = d_qtypecounters.at(i).value;
     if (count) {
       ret[i] = count;
@@ -77,7 +77,7 @@ map<uint8_t, uint64_t> ResponseStats::getRCodeResponseCounts() const
 {
   map<uint8_t, uint64_t> ret;
   uint64_t count;
-  for (unsigned int i = 0; i < 256; ++i) {
+  for (unsigned int i = 0; i < d_rcodecounters.size(); ++i) {
     count = d_rcodecounters.at(i).value;
     if (count) {
       ret[i] = count;
index 62f94e58417513191f522e4acb91cb9627325afa..0d89ca88ac7b97c2013171b8887ef55ee611205a 100644 (file)
@@ -45,7 +45,7 @@ private:
     mutable std::atomic<uint64_t> value;
   };
 
-  std::array<Counter, 65535> d_qtypecounters;
+  std::array<Counter, 65536> d_qtypecounters;
   std::array<Counter, 256> d_rcodecounters;
   pdns::AtomicHistogram d_sizecounters;
 };
diff --git a/regression-tests/tests/type65535-query/command b/regression-tests/tests/type65535-query/command
new file mode 100755 (executable)
index 0000000..4d77264
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+cleandig outpost.example.com TYPE65535
+
diff --git a/regression-tests/tests/type65535-query/description b/regression-tests/tests/type65535-query/description
new file mode 100644 (file)
index 0000000..7c4b779
--- /dev/null
@@ -0,0 +1 @@
+TYPE65535 queries crashed Auth 4.5.0.
\ No newline at end of file
diff --git a/regression-tests/tests/type65535-query/expected_result b/regression-tests/tests/type65535-query/expected_result
new file mode 100644 (file)
index 0000000..39db1b9
--- /dev/null
@@ -0,0 +1,3 @@
+1      example.com.    IN      SOA     86400   ns1.example.com. ahu.example.com. 2847484148 28800 7200 604800 86400
+Rcode: 0 (No Error), RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
+Reply to question for qname='outpost.example.com.', qtype=TYPE65535