From 5af86fdcdee2843d80d40dd1c22c137e471f9484 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Wed, 26 Oct 2016 10:00:39 +0200 Subject: [PATCH] rec: Don't crash on an empty query ring It obviously happens if stats-ringbuffer-entries is set to 0. --- pdns/pdns_recursor.cc | 5 +++-- pdns/rec_channel_rec.cc | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 487fabfe7..71033e391 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -586,7 +586,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++; @@ -667,7 +667,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 d23123207..9d029d34e 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -963,7 +963,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); } -- 2.40.0