summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2016-10-06 15:22:22 -0400
committerAdam <Adam@anope.org>2016-10-06 15:22:22 -0400
commitcf1289a26247a00fa74483ce4fef7500248f6f1e (patch)
treea3ede47acc0b092cb35933873f31112a99c2dae7
parent6d37e8ffb6a6111979732959e0d843b510d95419 (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/dns.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/modules/dns.cpp b/modules/dns.cpp
index 02c92b3c7..523b4044d 100644
--- a/modules/dns.cpp
+++ b/modules/dns.cpp
@@ -111,8 +111,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;
@@ -261,11 +260,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)