]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Validate settings in order in ValidateSettings() (#1475).
authorgenius3000 <genius3000@g3k.solutions>
Fri, 6 Apr 2018 15:08:30 +0000 (09:08 -0600)
committerPeter Powell <petpow@saberuk.com>
Fri, 6 Apr 2018 15:08:30 +0000 (16:08 +0100)
* Validate the settings in the same order as the parameter syntax
* Always validate Lines and Secs regardless of having a Diff
* Check Backlog for greater than Max as well as being disabled

src/modules/m_repeat.cpp

index 3e974c22194caf33db75b646fc293264306549c9..7ecdf21dc5dbb4b2f8c1ec7ab1bbd3e32b5f94b1 100644 (file)
@@ -306,39 +306,40 @@ class RepeatMode : public ParamMode<RepeatMode, SimpleExtItem<ChannelSettings> >
 
        bool ValidateSettings(LocalUser* source, Channel* channel, const std::string& parameter, const ChannelSettings& settings)
        {
-               if (settings.Backlog && !ms.MaxBacklog)
+               if (ms.MaxLines && settings.Lines > ms.MaxLines)
                {
-                       source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter,
-                               "Invalid repeat parameter. The server administrator has disabled backlog matching."));
+                       source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, InspIRCd::Format(
+                               "Invalid repeat parameter. The line number you specified is too great. Maximum allowed is %u.", ms.MaxLines)));
                        return false;
                }
 
-               if (settings.Diff)
+               if (ms.MaxSecs && settings.Seconds > ms.MaxSecs)
                {
-                       if (settings.Diff > ms.MaxDiff)
-                       {
-                               if (ms.MaxDiff == 0)
-                                       source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter,
-                                               "Invalid repeat parameter. The server administrator has disabled matching on edit distance."));
-                               else
-                                       source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, InspIRCd::Format(
-                                               "Invalid repeat parameter. The distance you specified is too great. Maximum allowed is %u.", ms.MaxDiff)));
-                               return false;
-                       }
+                       source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, InspIRCd::Format(
+                               "Invalid repeat parameter. The seconds you specified is too great. Maximum allowed is %u.", ms.MaxSecs)));
+                       return false;
+               }
 
-                       if (ms.MaxLines && settings.Lines > ms.MaxLines)
-                       {
+               if (settings.Diff && settings.Diff > ms.MaxDiff)
+               {
+                       if (ms.MaxDiff == 0)
+                               source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter,
+                                       "Invalid repeat parameter. The server administrator has disabled matching on edit distance."));
+                       else
                                source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, InspIRCd::Format(
-                                       "Invalid repeat parameter. The line number you specified is too great. Maximum allowed is %u.", ms.MaxLines)));
-                               return false;
-                       }
+                                       "Invalid repeat parameter. The distance you specified is too great. Maximum allowed is %u.", ms.MaxDiff)));
+                       return false;
+               }
 
-                       if (ms.MaxSecs && settings.Seconds > ms.MaxSecs)
-                       {
+               if (settings.Backlog && settings.Backlog > ms.MaxBacklog)
+               {
+                       if (ms.MaxBacklog == 0)
+                               source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter,
+                                       "Invalid repeat parameter. The server administrator has disabled backlog matching."));
+                       else
                                source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, InspIRCd::Format(
-                                       "Invalid repeat parameter. The seconds you specified is too great. Maximum allowed is %u.", ms.MaxSecs)));
-                               return false;
-                       }
+                                       "Invalid repeat paramter. The backlog you specified is too great. Maximum allowed is %u.", ms.MaxBacklog)));
+                       return false;
                }
 
                return true;