summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2017-12-11 13:16:06 +0000
committerPeter Powell <petpow@saberuk.com>2017-12-11 13:17:17 +0000
commitc4955b78dced7bc399135fc64c14750f2dfc0a2b (patch)
tree48790af309deaf74d0ec8f13fc7d0a3e0fc81596
parent17ee4cd4863aa4e6368916d858cbd1f5fdbe36ec (diff)
Don't allow users to set a zero channel limit.
Closes #451.
-rw-r--r--docs/conf/inspircd.conf.example5
-rw-r--r--src/coremods/core_channel/cmode_l.cpp5
-rw-r--r--src/coremods/core_channel/core_channel.cpp5
-rw-r--r--src/coremods/core_channel/core_channel.h1
4 files changed, 14 insertions, 2 deletions
diff --git a/docs/conf/inspircd.conf.example b/docs/conf/inspircd.conf.example
index 035f82a12..945041624 100644
--- a/docs/conf/inspircd.conf.example
+++ b/docs/conf/inspircd.conf.example
@@ -610,6 +610,11 @@
# 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"
diff --git a/src/coremods/core_channel/cmode_l.cpp b/src/coremods/core_channel/cmode_l.cpp
index eb16fd182..e71eb500e 100644
--- a/src/coremods/core_channel/cmode_l.cpp
+++ b/src/coremods/core_channel/cmode_l.cpp
@@ -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);
diff --git a/src/coremods/core_channel/core_channel.cpp b/src/coremods/core_channel/core_channel.cpp
index af71e2ced..161f618d1 100644
--- a/src/coremods/core_channel/core_channel.cpp
+++ b/src/coremods/core_channel/core_channel.cpp
@@ -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();
}
diff --git a/src/coremods/core_channel/core_channel.h b/src/coremods/core_channel/core_channel.h
index fa600cd17..c500add07 100644
--- a/src/coremods/core_channel/core_channel.h
+++ b/src/coremods/core_channel/core_channel.h
@@ -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);