Skip to content

Commit

Permalink
correct upper bounds on d_qtypecounters
Browse files Browse the repository at this point in the history
(cherry picked from commit 9949e87)
  • Loading branch information
Habbie committed Jul 22, 2021
1 parent 55eba36 commit 96cae2f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
12 changes: 6 additions & 6 deletions pdns/responsestats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand All @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion pdns/responsestats.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint64_t> d_sizecounters;
};
Expand Down
3 changes: 3 additions & 0 deletions regression-tests/tests/type65535-query/command
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
cleandig outpost.example.com TYPE65535

1 change: 1 addition & 0 deletions regression-tests/tests/type65535-query/description
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TYPE65535 queries crashed Auth 4.5.0.
3 changes: 3 additions & 0 deletions regression-tests/tests/type65535-query/expected_result
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 96cae2f

Please sign in to comment.