]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
core_dns Allow usage of id 65535
authorAttila Molnar <attilamolnar@hush.com>
Tue, 21 Apr 2015 13:05:49 +0000 (15:05 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Tue, 21 Apr 2015 13:05:49 +0000 (15:05 +0200)
src/coremods/core_dns.cpp

index f4559c08fe672cca508bb43f9305aaf7e55ada39..58c275c7ced1acffe44cf77234a4b3b968b253d5 100644 (file)
@@ -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)