From: Christian Hofstaedtler Date: Mon, 12 Oct 2015 10:38:43 +0000 (+0200) Subject: Ignore invalid/empty TKEY and TSIG records X-Git-Tag: dnsdist-1.0.0-alpha1~241 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6b3e413d29f26b19ee8b5a5a58e727b17379ea62;p=pdns Ignore invalid/empty TKEY and TSIG records --- 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; }