From 14d15d3d2a049b07e9cad2bc2970d1fa0d51af02 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Tue, 21 Apr 2015 15:05:49 +0200 Subject: [PATCH] core_dns Allow usage of id 65535 --- src/coremods/core_dns.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/coremods/core_dns.cpp b/src/coremods/core_dns.cpp index f4559c08f..58c275c7c 100644 --- a/src/coremods/core_dns.cpp +++ b/src/coremods/core_dns.cpp @@ -442,18 +442,18 @@ class MyManager : public Manager, public Timer, public EventHandler } public: - DNS::Request* requests[MAX_REQUEST_ID]; + DNS::Request* requests[MAX_REQUEST_ID+1]; MyManager(Module* c) : Manager(c), Timer(3600, true) { - for (int i = 0; i < MAX_REQUEST_ID; ++i) + for (unsigned int i = 0; i <= MAX_REQUEST_ID; ++i) requests[i] = NULL; ServerInstance->Timers.AddTimer(this); } ~MyManager() { - for (int i = 0; i < MAX_REQUEST_ID; ++i) + for (unsigned int i = 0; i <= MAX_REQUEST_ID; ++i) { DNS::Request* request = requests[i]; if (!request) @@ -476,14 +476,14 @@ class MyManager : public Manager, public Timer, public EventHandler int id; do { - id = ServerInstance->GenRandomInt(DNS::MAX_REQUEST_ID); + id = ServerInstance->GenRandomInt(DNS::MAX_REQUEST_ID+1); if (++tries == DNS::MAX_REQUEST_ID*5) { // If we couldn't find an empty slot this many times, do a sequential scan as a last // resort. If an empty slot is found that way, go on, otherwise throw an exception id = -1; - for (unsigned int i = 0; i < DNS::MAX_REQUEST_ID; i++) + for (unsigned int i = 0; i <= DNS::MAX_REQUEST_ID; i++) { if (!this->requests[i]) { @@ -807,7 +807,7 @@ class ModuleDNS : public Module void OnUnloadModule(Module* mod) { - for (int i = 0; i < MAX_REQUEST_ID; ++i) + for (unsigned int i = 0; i <= MAX_REQUEST_ID; ++i) { DNS::Request* req = this->manager.requests[i]; if (!req) -- 2.39.2