From 0a7f1670604433f5be3a6c4e18d96e8d7b45bbd0 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 19 Jul 2016 21:17:58 -0400 Subject: m_dns: accept unpacking the root domain, and don't consider exceptions from nameserver/additional record unpacking as fatal to query parsing --- modules/m_dns.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'modules/m_dns.cpp') diff --git a/modules/m_dns.cpp b/modules/m_dns.cpp index 648b40211..93f09246e 100644 --- a/modules/m_dns.cpp +++ b/modules/m_dns.cpp @@ -103,8 +103,7 @@ class Packet : public Query /* +1 pos either to one byte after the compression pointer or one byte after the ending \0 */ ++pos; - if (name.empty()) - throw SocketException("Unable to unpack name - no name"); + /* Empty names are valid (root domain) */ Log(LOG_DEBUG_2) << "Resolver: UnpackName successfully unpacked " << name; @@ -253,11 +252,18 @@ class Packet : public Query for (unsigned i = 0; i < ancount; ++i) this->answers.push_back(this->UnpackResourceRecord(input, len, packet_pos)); - for (unsigned i = 0; i < nscount; ++i) - this->authorities.push_back(this->UnpackResourceRecord(input, len, packet_pos)); + try + { + for (unsigned i = 0; i < nscount; ++i) + this->authorities.push_back(this->UnpackResourceRecord(input, len, packet_pos)); - for (unsigned i = 0; i < arcount; ++i) - this->additional.push_back(this->UnpackResourceRecord(input, len, packet_pos)); + for (unsigned i = 0; i < arcount; ++i) + this->additional.push_back(this->UnpackResourceRecord(input, len, packet_pos)); + } + catch (const SocketException &ex) + { + Log(LOG_DEBUG_2) << "Unable to parse ns/ar records: " << ex.GetReason(); + } } unsigned short Pack(unsigned char *output, unsigned short output_size) -- cgit