]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Don't allow users to set a zero channel limit.
authorPeter Powell <petpow@saberuk.com>
Mon, 11 Dec 2017 13:16:06 +0000 (13:16 +0000)
committerPeter Powell <petpow@saberuk.com>
Mon, 11 Dec 2017 13:17:17 +0000 (13:17 +0000)
Closes #451.

docs/conf/inspircd.conf.example
src/coremods/core_channel/cmode_l.cpp
src/coremods/core_channel/core_channel.cpp
src/coremods/core_channel/core_channel.h

index 035f82a12aabeb384ae8c64ab36fc00971d404c3..94504162463f744d285d1aada2e1866e84fa6dab 100644 (file)
          # banned from the server.
          xlinemessage="You're banned! Email irc@example.com with the ERROR line below for help."
 
+         # allowzerolimit: If enabled then allow a limit of 0 to be set on channels.
+         # This is non-standard behaviour and should only be enabled if you need to
+         # link with servers running 2.0. Defaults to yes.
+         allowzerolimit="no"
+
          # exemptchanops: exemptions for channel access restrictions based on prefix.
          exemptchanops="nonick:v flood:o"
 
index eb16fd182da50821e6f84c52e0757b730118121f..e71eb500e01ace4b363596c650bdde69493d38fd 100644 (file)
@@ -24,6 +24,7 @@
 
 ModeChannelLimit::ModeChannelLimit(Module* Creator)
        : ParamMode<ModeChannelLimit, LocalIntExt>(Creator, "limit", 'l')
+       , minlimit(0)
 {
 }
 
@@ -35,8 +36,8 @@ bool ModeChannelLimit::ResolveModeConflict(std::string &their_param, const std::
 
 ModeAction ModeChannelLimit::OnSet(User* user, Channel* chan, std::string& parameter)
 {
-       int limit = ConvToInt(parameter);
-       if (limit < 0)
+       size_t limit = ConvToNum<size_t>(parameter);
+       if (limit < minlimit)
                return MODEACTION_DENY;
 
        ext.set(chan, limit);
index af71e2ced19792e098f171cbb998508e9b868513..161f618d1359379f52831b0646c9023081e5ff52 100644 (file)
@@ -104,6 +104,11 @@ class CoreModChannel : public Module, public CheckExemption::EventListener
                        exempts[restriction] = prefix;
                }
                exemptions.swap(exempts);
+
+               // In 2.0 we allowed limits of 0 to be set. This is non-standard behaviour
+               // and will be removed in the next major release.
+               limitmode.minlimit = optionstag->getBool("allowzerolimit", true) ? 0 : 1;
+
                banmode.DoRehash();
        }
 
index fa600cd17e984667d530f5df5ab1538968250ea0..c500add07277331fe86a5ad67ffc503a2798a38b 100644 (file)
@@ -168,6 +168,7 @@ class ModeChannelKey : public ParamMode<ModeChannelKey, LocalStringExt>
 class ModeChannelLimit : public ParamMode<ModeChannelLimit, LocalIntExt>
 {
  public:
+       size_t minlimit;
        ModeChannelLimit(Module* Creator);
        bool ResolveModeConflict(std::string& their_param, const std::string& our_param, Channel* channel) CXX11_OVERRIDE;
        void SerializeParam(Channel* chan, intptr_t n, std::string& out);