diff options
author | Adam <Adam@anope.org> | 2016-07-19 21:17:58 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2016-07-19 21:17:58 -0400 |
commit | 0a7f1670604433f5be3a6c4e18d96e8d7b45bbd0 (patch) | |
tree | 3c54a95616cdd255b672e0ba93ac3983d85d133c | |
parent | d427772bd326d8db0c411cfda1e6583278a4b664 (diff) |
m_dns: accept unpacking the root domain, and don't consider exceptions from nameserver/additional record unpacking as fatal to query parsing
-rw-r--r-- | modules/m_dns.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
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) |