]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
core_dns Drop incoming packets containing a different question from what we asked
authorAttila Molnar <attilamolnar@hush.com>
Mon, 27 Apr 2015 17:28:00 +0000 (19:28 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Mon, 27 Apr 2015 17:28:00 +0000 (19:28 +0200)
include/modules/dns.h
src/coremods/core_dns.cpp

index 4da31b805407fc44fe236a3c48af3d2a92f8e4e7..cfa048184167e3c056fcd0046dc3cfce23106fc6 100644 (file)
@@ -92,6 +92,7 @@ namespace DNS
                Question() : type(QUERY_NONE) { }
                Question(const std::string& n, QueryType t) : name(n), type(t) { }
                bool operator==(const Question& other) const { return ((name == other.name) && (type == other.type)); }
+               bool operator!=(const Question& other) const { return (!(*this == other)); }
 
                struct hash
                {
index f4f85e2532f0bb6d54fd21ff25da084e8bbaecb3..d4214b9a5ec313be8b354063cd5072e8a7d33d56 100644 (file)
@@ -527,6 +527,13 @@ class MyManager : public Manager, public Timer, public EventHandler
                        return;
                }
 
+               if (static_cast<Question&>(*request) != recv_packet.question)
+               {
+                       // This can happen under high latency, drop it silently, do not fail the request
+                       ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Received an answer that isn't for a question we asked");
+                       return;
+               }
+
                if (recv_packet.flags & QUERYFLAGS_OPCODE)
                {
                        ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Received a nonstandard query");