Permalink
Browse files

rec: Don't crash on an empty query ring

It obviously happens if stats-ringbuffer-entries is set to 0.

(cherry picked from commit 5af86fd)
  • Loading branch information...
1 parent 49077a2 commit 1fa6e1b41b0497fca72412cec04ac96d412116ee @rgacogne rgacogne committed Oct 26, 2016
Showing with 4 additions and 3 deletions.
  1. +3 −2 pdns/pdns_recursor.cc
  2. +1 −1 pdns/rec_channel_rec.cc
@@ -590,7 +590,7 @@ void updateResponseStats(int res, const ComboAddress& remote, unsigned int packe
case RCode::ServFail:
if(t_servfailremotes) {
t_servfailremotes->push_back(remote);
- if(query) // packet cache
+ if(query && t_servfailqueryring) // packet cache
t_servfailqueryring->push_back(make_pair(*query, qtype));
}
g_stats.servFails++;
@@ -671,7 +671,8 @@ void startDoResolve(void *p)
{
DNSComboWriter* dc=(DNSComboWriter *)p;
try {
- t_queryring->push_back(make_pair(dc->d_mdp.d_qname, dc->d_mdp.d_qtype));
+ if (t_queryring)
+ t_queryring->push_back(make_pair(dc->d_mdp.d_qname, dc->d_mdp.d_qtype));
uint32_t maxanswersize= dc->d_tcp ? 65535 : min((uint16_t) 512, g_udpTruncationThreshold);
EDNSOpts edo;
@@ -942,7 +942,7 @@ vector<pair<DNSName,uint16_t> >* pleaseGetServfailQueryRing()
vector<query_t>* ret = new vector<query_t>();
if(!t_servfailqueryring)
return ret;
- ret->reserve(t_queryring->size());
+ ret->reserve(t_servfailqueryring->size());
for(const query_t& q : *t_servfailqueryring) {
ret->push_back(q);
}

0 comments on commit 1fa6e1b

Please sign in to comment.