From 6b3e413d29f26b19ee8b5a5a58e727b17379ea62 Mon Sep 17 00:00:00 2001 From: Christian Hofstaedtler Date: Mon, 12 Oct 2015 12:38:43 +0200 Subject: [PATCH] Ignore invalid/empty TKEY and TSIG records --- pdns/dnspacket.cc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/pdns/dnspacket.cc b/pdns/dnspacket.cc index 33fea5018..7a21eebff 100644 --- a/pdns/dnspacket.cc +++ b/pdns/dnspacket.cc @@ -481,10 +481,15 @@ bool DNSPacket::getTSIGDetails(TSIGRecordContent* trc, DNSName* keyname, string* bool gotit=false; for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) { if(i->first.d_type == QType::TSIG) { - *trc = *std::dynamic_pointer_cast(i->first.d_content); - - gotit=true; + // cast can fail, f.e. if d_content is an UnknownRecordContent. + shared_ptr content = std::dynamic_pointer_cast(i->first.d_content); + if (!content) { + L<first.d_name; + gotit=true; } } if(!gotit) @@ -507,7 +512,13 @@ bool DNSPacket::getTKEYRecord(TKEYRecordContent *tr, DNSName *keyname) const } if(i->first.d_type == QType::TKEY) { - *tr = *std::dynamic_pointer_cast(i->first.d_content); + // cast can fail, f.e. if d_content is an UnknownRecordContent. + shared_ptr content = std::dynamic_pointer_cast(i->first.d_content); + if (!content) { + L<first.d_name; gotit=true; } -- 2.40.0