]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fixes to some stuff that writes on memory it shouldn't (thanks psychon).
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 20 Jul 2008 08:53:56 +0000 (08:53 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 20 Jul 2008 08:53:56 +0000 (08:53 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10047 e03df62e-2008-0410-955e-edbf42e46eb7

12 files changed:
include/inspircd.h
src/channels.cpp
src/configreader.cpp
src/mode.cpp
src/modules/m_blockcaps.cpp
src/modules/m_chghost.cpp
src/modules/m_conn_umodes.cpp
src/modules/m_dnsbl.cpp
src/modules/m_ripemd160.cpp
src/modules/m_sethost.cpp
src/modules/m_spanningtree/override_map.cpp
src/socketengines/socketengine_epoll.cpp

index 002c4899a94957c80068c36b1ded854fe0a77175..fc0f2a04e03fa0635e2f1fe08fcd361d57afe380 100644 (file)
@@ -38,6 +38,8 @@
 #include <cmath>
 #include <cstring>
 #include <climits>
+
+#include <sstream>
 #include <string>
 #include <vector>
 #include <deque>
index 878fdc1a28dc1e30478e49ff56edd6cebe6f7822..8628148cf7d3d89ebf0ded664c1194b13e519f3a 100644 (file)
@@ -31,7 +31,7 @@ Channel::Channel(InspIRCd* Instance, const std::string &cname, time_t ts) : Serv
 
 
        maxbans = topicset = limit = 0;
-       memset(&modes, 0, 64);
+       modes.reset();
 }
 
 void Channel::SetMode(char mode,bool mode_on)
index a302dd6ea2d451e901f902d65af894fba2a21bca..117546f0938bffe9cfe4187ba308526dd3cf1537 100644 (file)
@@ -301,7 +301,7 @@ bool InitializeDisabledCommands(const char* data, InspIRCd* ServerInstance)
 
 bool ValidateDisabledUModes(ServerConfig* conf, const char*, const char*, ValueItem &data)
 {
-       memset(conf->DisabledUModes, 0, 64);
+       memset(conf->DisabledUModes, 0, sizeof(conf->DisabledUModes));
        for (const unsigned char* p = (const unsigned char*)data.GetString(); *p; ++p)
        {
                if (*p < 'A' || *p > ('A' + 64)) throw CoreException(std::string("Invalid usermode ")+(char)*p+" was found.");
@@ -312,7 +312,7 @@ bool ValidateDisabledUModes(ServerConfig* conf, const char*, const char*, ValueI
 
 bool ValidateDisabledCModes(ServerConfig* conf, const char*, const char*, ValueItem &data)
 {
-       memset(conf->DisabledCModes, 0, 64);
+       memset(conf->DisabledCModes, 0, sizeof(conf->DisabledCModes));
        for (const unsigned char* p = (const unsigned char*)data.GetString(); *p; ++p)
        {
                if (*p < 'A' || *p > ('A' + 64)) throw CoreException(std::string("Invalid chanmode ")+(char)*p+" was found.");
@@ -414,7 +414,7 @@ bool ValidateRules(ServerConfig* conf, const char*, const char*, ValueItem &data
 
 bool ValidateModeLists(ServerConfig* conf, const char*, const char*, ValueItem &data)
 {
-       memset(conf->HideModeLists, 0, 256);
+       memset(conf->HideModeLists, 0, sizeof(conf->HideModeLists));
        for (const unsigned char* x = (const unsigned char*)data.GetString(); *x; ++x)
                conf->HideModeLists[*x] = true;
        return true;
@@ -422,7 +422,7 @@ bool ValidateModeLists(ServerConfig* conf, const char*, const char*, ValueItem &
 
 bool ValidateExemptChanOps(ServerConfig* conf, const char*, const char*, ValueItem &data)
 {
-       memset(conf->ExemptChanOps, 0, 256);
+       memset(conf->ExemptChanOps, 0, sizeof(conf->ExemptChanOps));
        for (const unsigned char* x = (const unsigned char*)data.GetString(); *x; ++x)
                conf->ExemptChanOps[*x] = true;
        return true;
index bce2b20191493a115f6957470bbe4d1f71f06847..faa70a29f082438e0fd381f548bbf7918bcf3b27 100644 (file)
@@ -1221,5 +1221,5 @@ ModeParser::ModeParser(InspIRCd* Instance) : ServerInstance(Instance)
                this->AddMode(modes[index]);
 
        seq = 0;
-       memset(&sent, 0, 256);
+       memset(&sent, 0, sizeof(sent));
 }
index 23658a9fa3e36883551bc725056638331af6f40a..31542befda534203dc354c2a2a4662d041c9d7a2 100644 (file)
@@ -107,7 +107,7 @@ public:
                std::string hmap = Conf.ReadValue("blockcaps", "capsmap", 0);
                if (hmap.empty())
                        hmap = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-               memset(&capsmap, 0, 255);
+               memset(capsmap, 0, sizeof(capsmap));
                for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++)
                        capsmap[(unsigned char)*n] = 1;
                if (percent < 1 || percent > 100)
index b1d9ade7cd6207a480377e760855e54de94777cd..ad5a9b562a5caf4086889992b0160fde7fb59f8b 100644 (file)
@@ -103,7 +103,7 @@ class ModuleChgHost : public Module
                if (hmap.empty())
                        hmap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789";
 
-               memset(&hostmap, 0, 255);
+               memset(hostmap, 0, sizeof(hostmap));
                for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++)
                        hostmap[(unsigned char)*n] = 1;
        }
index 42c0ec660d4022f3c2ead5ec523c8e66db59da00..2489f2a1f3166298627992041c495fc27f600061 100644 (file)
@@ -56,7 +56,8 @@ class ModuleModesOnConnect : public Module
 
                // Backup and zero out the disabled usermodes, so that we can override them here.
                char save[64];
-               memcpy(save, ServerInstance->Config->DisabledUModes, 64);
+               memcpy(save, ServerInstance->Config->DisabledUModes,
+                               sizeof(ServerInstance->Config->DisabledUModes));
                memset(ServerInstance->Config->DisabledUModes, 0, 64);
 
                for (int j = 0; j < Conf->Enumerate("connect"); j++)
index 3b68e1c94356fae6602be1d385bdc2a250219b7f..c4ab5a7e4d986b419cca7b5db9c06787702d42d2 100644 (file)
@@ -247,7 +247,7 @@ class ModuleDNSBL : public Module
                        }
                        else
                        {
-                               memset(e->records, 0, 256);
+                               memset(e->records, 0, sizeof(e->records));
                                e->type = DNSBLConfEntry::A_RECORD;
                                irc::portparser portrange(MyConf->ReadValue("dnsbl", "records", i), false);
                                long item = -1;
index 007a89f09c5f0cb44d1613b0d4104d930c18af69..ab5b23ad188995577fe33c429ad6483f99d40f1f 100644 (file)
@@ -379,7 +379,7 @@ class ModuleRIPEMD160 : public Module
                unsigned int i;                                 /* counter       */
                dword        X[16];                             /* message words */
 
-               memset(X, 0, 16*sizeof(dword));
+               memset(X, 0, sizeof(X));
 
                /* put bytes from strptr into X */
                for (i=0; i<(lswlen&63); i++) {
@@ -393,7 +393,7 @@ class ModuleRIPEMD160 : public Module
                if ((lswlen & 63) > 55) {
                        /* length goes to next block */
                        compress(MDbuf, X);
-                       memset(X, 0, 16*sizeof(dword));
+                       memset(X, 0, sizeof(X));
                }
 
                /* append length in bits*/
index b84f11acf5bcd350c9e41418d269b1c9f450ae88..fbc71ff2f03027c61a9f6f7968477ee411b947c6 100644 (file)
@@ -86,7 +86,7 @@ class ModuleSetHost : public Module
                if (hmap.empty())
                        hmap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789";
 
-               memset(&hostmap, 0, 255);
+               memset(hostmap, 0, sizeof(hostmap));
                for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++)
                        hostmap[(unsigned char)*n] = 1;
        }
index b17e266b23b32cf468b92907209807ea3cf77d9d..fca32b85b0904372bddcb4dcfb9dc8913096ccac 100644 (file)
@@ -43,7 +43,7 @@ void ModuleSpanningTree::ShowMap(TreeServer* Current, User* user, int depth, cha
                // For Aligning, we need to work out exactly how deep this thing is, and produce
                // a 'Spacer' String to compensate.
                char spacer[40];
-               memset(spacer,' ',40);
+               memset(spacer,' ',sizeof(spacer));
                if ((40 - Current->GetName().length() - depth) > 1) {
                        spacer[40 - Current->GetName().length() - depth] = '\0';
                }
@@ -55,7 +55,7 @@ void ModuleSpanningTree::ShowMap(TreeServer* Current, User* user, int depth, cha
                float percent;
                char text[128];
                /* Neat and tidy default values, as we're dealing with a matrix not a simple string */
-               memset(text, 0, 128);
+               memset(text, 0, sizeof(text));
 
                if (ServerInstance->Users->clientlist->size() == 0)
                {
index 5552cccf6b2a9167f4f72f03b7445cbfa60ad682..6b89544127d40a6afe34b070a28c938823f3522d 100644 (file)
@@ -68,7 +68,7 @@ bool EPollEngine::AddFd(EventHandler* eh)
        }
 
        struct epoll_event ev;
-       memset(&ev,0,sizeof(struct epoll_event));
+       memset(&ev,0,sizeof(ev));
        eh->Readable() ? ev.events = EPOLLIN : ev.events = EPOLLOUT;
        ev.data.fd = fd;
        int i = epoll_ctl(EngineHandle, EPOLL_CTL_ADD, fd, &ev);
@@ -91,7 +91,7 @@ void EPollEngine::WantWrite(EventHandler* eh)
         * status for us and saves us a call.
         */
        struct epoll_event ev;
-       memset(&ev,0,sizeof(struct epoll_event));
+       memset(&ev,0,sizeof(ev));
        ev.events = EPOLLOUT;
        ev.data.fd = eh->GetFd();
        epoll_ctl(EngineHandle, EPOLL_CTL_MOD, eh->GetFd(), &ev);
@@ -107,7 +107,7 @@ bool EPollEngine::DelFd(EventHandler* eh, bool force)
        }
 
        struct epoll_event ev;
-       memset(&ev,0,sizeof(struct epoll_event));
+       memset(&ev,0,sizeof(ev));
        eh->Readable() ? ev.events = EPOLLIN : ev.events = EPOLLOUT;
        ev.data.fd = fd;
        int i = epoll_ctl(EngineHandle, EPOLL_CTL_DEL, fd, &ev);
@@ -181,7 +181,7 @@ int EPollEngine::DispatchEvents()
                {
                        WriteEvents++;
                        struct epoll_event ev;
-                       memset(&ev,0,sizeof(struct epoll_event));
+                       memset(&ev,0,sizeof(ev));
                        ev.events = EPOLLIN;
                        ev.data.fd = events[j].data.fd;
                        epoll_ctl(EngineHandle, EPOLL_CTL_MOD, events[j].data.fd, &ev);