]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/treesocket2.cpp
NEVER use the two-param assign unless you want your string padding to len bytes with \0!
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / treesocket2.cpp
index c99402af07b1ca8b1a8f7c28f26c7189b8649b1e..5d2471b2cd1b8333d6243c0f4bbf6e2cb525a668 100644 (file)
@@ -366,10 +366,8 @@ bool TreeSocket::ProcessLine(std::string &line)
                                User* user = Instance->FindNick(prefix);
                                if (user)
                                {
-                                       const char* ptrs[127];
-                                       for (size_t n = 0; (n < params.size()) && (n < 127); ++n)
-                                               ptrs[n] = params[n].c_str();
-                                       return Utils->Creator->HandleMap(ptrs, params.size(), user);
+                                       std::vector<std::string> p(params.begin(), params.end());
+                                       return Utils->Creator->HandleMap(p, user);
                                }
                        }
                        else if (command == "SERVER")
@@ -392,10 +390,6 @@ bool TreeSocket::ProcessLine(std::string &line)
                        {
                                return this->ForceTopic(prefix,params);
                        }
-                       else if (command == "REHASH")
-                       {
-                               return this->RemoteRehash(prefix,params);
-                       }
                        else if (command == "METADATA")
                        {
                                return this->MetaData(prefix,params);
@@ -481,12 +475,6 @@ bool TreeSocket::ProcessLine(std::string &line)
                                }
                                return true;
                        }
-                       else if (command == "OPERNOTICE")
-                       {
-                               if (params.size() >= 1)
-                                       Instance->SNO->WriteToSnoMask('A', "From " + (ServerSource ? ServerSource->GetName().c_str() : prefix) + ": " + params[0]);
-                               return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
-                       }
                        else if (command == "MODENOTICE")
                        {
                                if (params.size() >= 2)
@@ -501,8 +489,9 @@ bool TreeSocket::ProcessLine(std::string &line)
                                if (params.size() >= 2)
                                {
                                        Instance->SNO->WriteToSnoMask(*(params[0].c_str()), "From " + (ServerSource ? ServerSource->GetName().c_str() : prefix) + ": "+ params[1]);
+                                       return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
                                }
-                               return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
+
                        }
                        else if (command == "BURST")
                        {
@@ -534,9 +523,7 @@ bool TreeSocket::ProcessLine(std::string &line)
                        else if (command == "MODE")
                        {
                                // Server-prefix MODE.
-                               const char* modelist[MAXPARAMETERS];
-                               for (size_t i = 0; i < params.size(); i++)
-                                       modelist[i] = params[i].c_str();
+                               std::vector<std::string> modelist(params.begin(), params.end());
 
                                /* We don't support this for channel mode changes any more! */
                                if (params.size() >= 1)
@@ -549,7 +536,7 @@ bool TreeSocket::ProcessLine(std::string &line)
                                }
                                        
                                // Insert into the parser
-                               this->Instance->SendMode(modelist, params.size(), this->Instance->FakeClient);
+                               this->Instance->SendMode(modelist, this->Instance->FakeClient);
                                
                                // Pass out to the network
                                return Utils->DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params);
@@ -602,27 +589,25 @@ bool TreeSocket::ProcessLine(std::string &line)
                                }
                                        
                                // its a user
-                               const char* strparams[127];
-                               for (unsigned int q = 0; q < params.size(); q++)
-                               {
-                                       strparams[q] = params[q].c_str();
-                               }
+                               std::vector<std::string> strparams(params.begin(), params.end());
 
-                               switch (this->Instance->CallCommandHandler(command.c_str(), strparams, params.size(), who))
+                               switch (this->Instance->CallCommandHandler(command.c_str(), strparams, who))
                                {
                                        case CMD_INVALID:
-                                               // command is irc::string, hence ugliness
+                                               /*
+                                                * XXX: command is irc::string, hence ugliness
+                                                */
                                                this->SendError("Unrecognised or malformed command '" + std::string(command.c_str()) + "' -- possibly loaded mismatched modules");
                                                return false;
                                                break;
-                                       /*
-                                        * CMD_LOCALONLY is aliased to CMD_FAILURE, so this won't go out onto the network.
-                                        */
                                        case CMD_FAILURE:
+                                               /*
+                                                * CMD_LOCALONLY is aliased to CMD_FAILURE, so this won't go out onto the network.
+                                                */
                                                return true;
                                                break;
                                        default:
-                                               /* CMD_SUCCESS and CMD_USER_DELETED fall through here */
+                                               /* CMD_SUCCESS falls through here */
                                                break;
                                }
 
@@ -687,18 +672,19 @@ void TreeSocket::OnClose()
 
 int TreeSocket::OnIncomingConnection(int newsock, char* ip)
 {
-       /* To prevent anyone from attempting to flood opers/DDoS by connecting to the server port,
-        * or discovering if this port is the server port, we don't allow connections from any
-        * IPs for which we don't have a link block.
-        */
        bool found = false;
 
        found = (std::find(Utils->ValidIPs.begin(), Utils->ValidIPs.end(), ip) != Utils->ValidIPs.end());
        if (!found)
        {
                for (std::vector<std::string>::iterator i = Utils->ValidIPs.begin(); i != Utils->ValidIPs.end(); i++)
-                       if (irc::sockets::MatchCIDR(ip, (*i).c_str()))
+               {
+                       if ((*i) == "*" || irc::sockets::MatchCIDR(ip, (*i).c_str()))
+                       {
                                found = true;
+                               break;
+                       }
+               }
 
                if (!found)
                {