]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_svshold.cpp
m_svshold Fix crash when called with 2 params, only triggerable by u-lines
[user/henk/code/inspircd.git] / src / modules / m_svshold.cpp
index 37288a32299433549be19abf525b44f443ee5491..d2269839d94bf95d74cade0a14a750e6c396395e 100644 (file)
@@ -123,6 +123,9 @@ class CommandSvshold : public Command
                }
                else
                {
+                       if (parameters.size() < 3)
+                               return CMD_FAILURE;
+
                        // Adding - XXX todo make this respect <insane> tag perhaps..
                        long duration = ServerInstance->Duration(parameters[1]);
                        SVSHold* r = new SVSHold(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), parameters[0].c_str());
@@ -136,7 +139,8 @@ class CommandSvshold : public Command
                                else
                                {
                                        time_t c_requires_crap = duration + ServerInstance->Time();
-                                       ServerInstance->SNO->WriteGlobalSno('x', "%s added timed SVSHOLD for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str());
+                                       std::string timestr = ServerInstance->TimeString(c_requires_crap);
+                                       ServerInstance->SNO->WriteGlobalSno('x', "%s added timed SVSHOLD for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), timestr.c_str(), parameters[2].c_str());
                                }
                        }
                        else
@@ -151,7 +155,7 @@ class CommandSvshold : public Command
 
        RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
        {
-               return ROUTE_LOCALONLY;
+               return ROUTE_BROADCAST;
        }
 };
 
@@ -163,14 +167,17 @@ class ModuleSVSHold : public Module
 
  public:
        ModuleSVSHold() : cmd(this)
+       {
+       }
+
+       void init()
        {
                ServerInstance->XLines->RegisterFactory(&s);
-               ServerInstance->AddCommand(&cmd);
+               ServerInstance->Modules->AddService(cmd);
                Implementation eventlist[] = { I_OnUserPreNick, I_OnStats };
-               ServerInstance->Modules->Attach(eventlist, this, 2);
+               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
-
        virtual ModResult OnStats(char symbol, User* user, string_list &out)
        {
                if(symbol != 'S')