]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_blockcaps.cpp
Fixes to some stuff that writes on memory it shouldn't (thanks psychon).
[user/henk/code/inspircd.git] / src / modules / m_blockcaps.cpp
index 88d7ab5f4d4a9f755785f842f80b7e92e20f4a2f..31542befda534203dc354c2a2a4662d041c9d7a2 100644 (file)
@@ -31,7 +31,7 @@ class ModuleBlockCAPS : public Module
        unsigned int minlen;
        char capsmap[256];
 public:
-       
+
        ModuleBlockCAPS(InspIRCd* Me) : Module(Me)
        {
                OnRehash(NULL,"");
@@ -69,18 +69,24 @@ public:
                        {
                                int caps = 0;
                                const char* actstr = "\1ACTION ";
+                               int act = 0;
 
                                for (std::string::iterator i = text.begin(); i != text.end(); i++)
                                {
                                        /* Smart fix for suggestion from Jobe, ignore CTCP ACTION (part of /ME) */
-                                       if (*actstr && *i == *actstr++)
+                                       if (*actstr && *i == *actstr++ && act != -1)
+                                       {
+                                               act++;
                                                continue;
+                                       }
+                                       else
+                                               act = -1;
 
                                        caps += capsmap[(unsigned char)*i];
                                }
                                if ( ((caps*100)/(int)text.length()) >= percent )
                                {
-                                       user->WriteServ( "404 %s %s :Your line cannot be more than %d%% capital letters if it is %d or more letters long", user->nick, c->name, percent, minlen);
+                                       user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s %s :Your line cannot be more than %d%% capital letters if it is %d or more letters long", user->nick.c_str(), c->name.c_str(), percent, minlen);
                                        return 1;
                                }
                        }
@@ -101,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)