From: Remi Gacogne Date: Wed, 26 Oct 2016 08:00:39 +0000 (+0200) Subject: rec: Don't crash on an empty query ring X-Git-Tag: rec-4.0.4~5^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F4805%2Fhead;p=thirdparty%2Fpdns.git rec: Don't crash on an empty query ring It obviously happens if stats-ringbuffer-entries is set to 0. (cherry picked from commit 5af86fdcdee2843d80d40dd1c22c137e471f9484) --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 5e73fbac32..306b0955df 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.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; diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index f603d86804..e02f77a462 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -942,7 +942,7 @@ vector >* pleaseGetServfailQueryRing() vector* ret = new vector(); 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); }