Skip to content

Commit

Permalink
Merge pull request #15139 from omoerbeek/rec-bound-check-for-future
Browse files Browse the repository at this point in the history
rec: check bounds of rcode stats counter index (safe right now)
  • Loading branch information
omoerbeek authored Feb 11, 2025
2 parents 9e5db7f + 8530269 commit 5569b42
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pdns/recursordist/lwres.hh
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ public:
}

vector<DNSRecord> d_records;
uint32_t d_usec{0};
int d_rcode{0};
bool d_validpacket{false};
bool d_aabit{false}, d_tcbit{false};
uint32_t d_usec{0};
bool d_haveEDNS{false};
};

Expand Down
4 changes: 2 additions & 2 deletions pdns/recursordist/rec-tcounters.hh
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ struct Counters
}
return *this;
}
static const size_t numberoOfRCodes = 16;
std::array<uint64_t, numberoOfRCodes> rcodeCounters;
static const size_t numberOfRCodes = 16;
std::array<uint64_t, numberOfRCodes> rcodeCounters;
};
// An RCodes histogram
RCodeCounters auth{};
Expand Down
4 changes: 3 additions & 1 deletion pdns/recursordist/syncres.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5552,7 +5552,9 @@ bool SyncRes::doResolveAtThisIP(const std::string& prefix, const DNSName& qname,
}

accountAuthLatency(lwr.d_usec, remoteIP.sin4.sin_family);
++t_Counters.at(rec::RCode::auth).rcodeCounters.at(static_cast<uint8_t>(lwr.d_rcode));
if (lwr.d_rcode >= 0 && lwr.d_rcode < static_cast<decltype(lwr.d_rcode)>(t_Counters.at(rec::RCode::auth).rcodeCounters.size())) {
++t_Counters.at(rec::RCode::auth).rcodeCounters.at(static_cast<uint8_t>(lwr.d_rcode));
}

if (!dontThrottle) {
dontThrottle = shouldNotThrottle(&nsName, &remoteIP);
Expand Down

0 comments on commit 5569b42

Please sign in to comment.