]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_rline.cpp
Fix copying too much data into the remote endpoint field.
[user/henk/code/inspircd.git] / src / modules / m_rline.cpp
index bf6a64d84ce3398ff62d4d13575d54489b172a4a..1247e81d3956a6469ad8c9973cef47396504bae5 100644 (file)
@@ -32,7 +32,7 @@ class RLine : public XLine
 {
  public:
 
-       /** Create a R-Line.
+       /** Create a R-line.
         * @param s_time The set time
         * @param d The duration of the xline
         * @param src The sender of the xline
@@ -40,7 +40,7 @@ class RLine : public XLine
         * @param regex Pattern to match with
         * @
         */
-       RLine(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& regexs, dynamic_reference<RegexFactory>& rxfactory)
+       RLine(time_t s_time, unsigned long d, const std::string& src, const std::string& re, const std::string& regexs, dynamic_reference<RegexFactory>& rxfactory)
                : XLine(s_time, d, src, re, "R")
                , matchtext(regexs)
        {
@@ -81,7 +81,7 @@ class RLine : public XLine
                        if (ServerInstance->XLines->AddLine(zl, NULL))
                        {
                                std::string timestr = InspIRCd::TimeString(zl->expiry);
-                               ServerInstance->SNO->WriteToSnoMask('x', "Z-line added due to R-line match on *@%s%s%s: %s",
+                               ServerInstance->SNO->WriteToSnoMask('x', "Z-line added due to R-line match on %s%s%s: %s",
                                        zl->ipaddr.c_str(), zl->duration ? " to expire on " : "", zl->duration ? timestr.c_str() : "", zl->reason.c_str());
                                added_zline = true;
                        }
@@ -114,7 +114,7 @@ class RLineFactory : public XLineFactory
 
        /** Generate a RLine
         */
-       XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask) CXX11_OVERRIDE
+       XLine* Generate(time_t set_time, unsigned long duration, const std::string& source, const std::string& reason, const std::string& xline_specific_mask) CXX11_OVERRIDE
        {
                if (!rxfactory)
                {
@@ -147,7 +147,12 @@ class CommandRLine : public Command
                {
                        // Adding - XXX todo make this respect <insane> tag perhaps..
 
-                       unsigned long duration = InspIRCd::Duration(parameters[1]);
+                       unsigned long duration;
+                       if (!InspIRCd::Duration(parameters[1], duration))
+                       {
+                               user->WriteNotice("*** Invalid duration for R-line.");
+                               return CMD_FAILURE;
+                       }
                        XLine *r = NULL;
 
                        try
@@ -179,7 +184,7 @@ class CommandRLine : public Command
                                else
                                {
                                        delete r;
-                                       user->WriteNotice("*** R-Line for " + parameters[0] + " already exists");
+                                       user->WriteNotice("*** R-line for " + parameters[0] + " already exists.");
                                }
                        }
                }
@@ -191,7 +196,7 @@ class CommandRLine : public Command
                        }
                        else
                        {
-                               user->WriteNotice("*** R-Line " + parameters[0] + " not found in list, try /stats R.");
+                               user->WriteNotice("*** R-line " + parameters[0] + " not found in list, try /stats R.");
                        }
                }
 
@@ -274,15 +279,15 @@ class ModuleRLine : public Module, public Stats::EventListener
                if (!rxfactory)
                {
                        if (newrxengine.empty())
-                               ServerInstance->SNO->WriteToSnoMask('a', "WARNING: No regex engine loaded - R-Line functionality disabled until this is corrected.");
+                               ServerInstance->SNO->WriteToSnoMask('a', "WARNING: No regex engine loaded - R-line functionality disabled until this is corrected.");
                        else
-                               ServerInstance->SNO->WriteToSnoMask('a', "WARNING: Regex engine '%s' is not loaded - R-Line functionality disabled until this is corrected.", newrxengine.c_str());
+                               ServerInstance->SNO->WriteToSnoMask('a', "WARNING: Regex engine '%s' is not loaded - R-line functionality disabled until this is corrected.", newrxengine.c_str());
 
                        ServerInstance->XLines->DelAll(f.GetType());
                }
                else if ((!initing) && (rxfactory.operator->() != factory))
                {
-                       ServerInstance->SNO->WriteToSnoMask('a', "Regex engine has changed, removing all R-Lines");
+                       ServerInstance->SNO->WriteToSnoMask('a', "Regex engine has changed, removing all R-lines.");
                        ServerInstance->XLines->DelAll(f.GetType());
                }
 
@@ -326,7 +331,7 @@ class ModuleRLine : public Module, public Stats::EventListener
 
        void OnUnloadModule(Module* mod) CXX11_OVERRIDE
        {
-               // If the regex engine became unavailable or has changed, remove all rlines
+               // If the regex engine became unavailable or has changed, remove all R-lines.
                if (!rxfactory)
                {
                        ServerInstance->XLines->DelAll(f.GetType());