]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/mode.cpp
Explicitly disallow mode prefixes > 126, to prevent excess muppetry by 3rd party...
[user/henk/code/inspircd.git] / src / mode.cpp
index c388742293d03c8375983e8d37b0c55e2f5c5fe0..db120cfe587a59be26b676815fbc44f4002b8f90 100644 (file)
@@ -484,7 +484,7 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
 
                                                                        /* Yerk, invalid! */
                                                                        if ((parameter.find(':') == 0) || (parameter.rfind(' ') != std::string::npos))
-                                                                               parameter = "";
+                                                                               parameter.clear();
                                                                }
                                                                else
                                                                {
@@ -691,7 +691,7 @@ bool ModeParser::AddMode(ModeHandler* mh, unsigned const char modeletter)
         * If they do that, thats their problem, and if i ever EVER see an
         * official InspIRCd developer do that, i'll beat them with a paddle!
         */
-       if ((mh->GetModeChar() < 'A') || (mh->GetModeChar() > 'z'))
+       if ((mh->GetModeChar() < 'A') || (mh->GetModeChar() > 'z') || (mh->GetPrefix() > 126))
                return false;
 
        /* A mode prefix of ',' is not acceptable, it would fuck up server to server.
@@ -783,6 +783,9 @@ std::string ModeParser::ChannelModeList()
 
        for (unsigned char mode = 'A'; mode <= 'z'; mode++)
        {
+               if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h'))
+                       continue;
+
                unsigned char pos = (mode-65) | MASK_CHANNEL;
 
                if (modehandlers[pos])
@@ -799,6 +802,9 @@ std::string ModeParser::ParaModeList()
 
        for (unsigned char mode = 'A'; mode <= 'z'; mode++)
        {
+               if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h'))
+                       continue;
+
                unsigned char pos = (mode-65) | MASK_CHANNEL;
 
                if ((modehandlers[pos]) && (modehandlers[pos]->GetNumParams(true)))
@@ -859,6 +865,9 @@ std::string ModeParser::ChanModes()
 
        for (unsigned char mode = 'A'; mode <= 'z'; mode++)
        {
+               if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h'))
+                       continue;
+
                unsigned char pos = (mode-65) | MASK_CHANNEL;
                 /* One parameter when adding */
                if (modehandlers[pos])
@@ -912,6 +921,9 @@ std::string ModeParser::BuildPrefixes()
 
        for (unsigned char mode = 'A'; mode <= 'z'; mode++)
        {
+               if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h'))
+                       continue;
+
                unsigned char pos = (mode-65) | MASK_CHANNEL;
 
                if ((modehandlers[pos]) && (modehandlers[pos]->GetPrefix()))