From 96cae2fd21054b383a16c569a363a50f71808cd9 Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Thu, 15 Jul 2021 15:47:18 +0200 Subject: [PATCH] correct upper bounds on d_qtypecounters (cherry picked from commit 9949e87aad7968d929cd110a8a9bcfa86b9a9d48) --- pdns/responsestats.cc | 12 ++++++------ pdns/responsestats.hh | 2 +- regression-tests/tests/type65535-query/command | 3 +++ regression-tests/tests/type65535-query/description | 1 + .../tests/type65535-query/expected_result | 3 +++ 5 files changed, 14 insertions(+), 7 deletions(-) create mode 100755 regression-tests/tests/type65535-query/command create mode 100644 regression-tests/tests/type65535-query/description create mode 100644 regression-tests/tests/type65535-query/expected_result diff --git a/pdns/responsestats.cc b/pdns/responsestats.cc index a41add2630..8397e6bab1 100644 --- a/pdns/responsestats.cc +++ b/pdns/responsestats.cc @@ -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 ResponseStats::getQTypeResponseCounts() const { map 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 ResponseStats::getRCodeResponseCounts() const { map 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; diff --git a/pdns/responsestats.hh b/pdns/responsestats.hh index 421c814cfc..61cce55580 100644 --- a/pdns/responsestats.hh +++ b/pdns/responsestats.hh @@ -45,7 +45,7 @@ private: mutable std::atomic value; }; - std::array d_qtypecounters; + std::array d_qtypecounters; std::array 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 index 0000000000..4d772643b8 --- /dev/null +++ b/regression-tests/tests/type65535-query/command @@ -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 index 0000000000..7c4b77998c --- /dev/null +++ b/regression-tests/tests/type65535-query/description @@ -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 index 0000000000..39db1b923f --- /dev/null +++ b/regression-tests/tests/type65535-query/expected_result @@ -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 -- 2.47.2