summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorlinuxdaemon <linuxdaemon@users.noreply.github.com>2018-12-21 12:37:22 -0600
committerPeter Powell <petpow@saberuk.com>2018-12-21 19:37:22 +0100
commit7530285740c2db1bc4457859b0d5f2436e0ed113 (patch)
tree89635613725a1b7ad6e262d7e3035a518d42e8d2 /src/modules
parent60ae49b62a371791ebbd9e4b131e33b857873f06 (diff)
Only parse valid durations, don't treat invalid multipliers as seconds (#1538)
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_cban.cpp7
-rw-r--r--src/modules/m_chanhistory.cpp4
-rw-r--r--src/modules/m_dccallow.cpp6
-rw-r--r--src/modules/m_filter.cpp6
-rw-r--r--src/modules/m_repeat.cpp7
-rw-r--r--src/modules/m_rline.cpp7
-rw-r--r--src/modules/m_setidle.cpp4
-rw-r--r--src/modules/m_shun.cpp6
-rw-r--r--src/modules/m_svshold.cpp7
-rw-r--r--src/modules/m_timedbans.cpp6
10 files changed, 45 insertions, 15 deletions
diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp
index 250acd2b5..e0768aa88 100644
--- a/src/modules/m_cban.cpp
+++ b/src/modules/m_cban.cpp
@@ -111,7 +111,12 @@ class CommandCBan : public Command
else
{
// 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 CBan");
+ return CMD_FAILURE;
+ }
const char *reason = (parameters.size() > 2) ? parameters[2].c_str() : "No reason supplied";
CBan* r = new CBan(ServerInstance->Time(), duration, user->nick.c_str(), reason, parameters[0].c_str());
diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp
index 47e27172c..1057e63b6 100644
--- a/src/modules/m_chanhistory.cpp
+++ b/src/modules/m_chanhistory.cpp
@@ -72,8 +72,8 @@ class HistoryMode : public ParamMode<HistoryMode, SimpleExtItem<HistoryList> >
}
unsigned int len = ConvToNum<unsigned int>(parameter.substr(0, colon));
- unsigned int time = InspIRCd::Duration(duration);
- if (len == 0 || (len > maxlines && IS_LOCAL(source)))
+ unsigned long time;
+ if (!InspIRCd::Duration(duration, time) || len == 0 || (len > maxlines && IS_LOCAL(source)))
{
source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter));
return MODEACTION_DENY;
diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp
index 85f9d20d0..d9e26d28f 100644
--- a/src/modules/m_dccallow.cpp
+++ b/src/modules/m_dccallow.cpp
@@ -219,7 +219,11 @@ class CommandDccallow : public Command
}
else
{
- length = InspIRCd::Duration(parameters[1]);
+ if (!InspIRCd::Duration(parameters[1], length))
+ {
+ user->WriteNotice("*** Invalid duration for DCC allow");
+ return CMD_FAILURE;
+ }
}
if (!InspIRCd::IsValidMask(mask))
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index 357fbf738..0c8b81e4b 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -251,7 +251,11 @@ CmdResult CommandFilter::Handle(User* user, const Params& parameters)
{
if (parameters.size() >= 5)
{
- duration = InspIRCd::Duration(parameters[3]);
+ if (!InspIRCd::Duration(parameters[3], duration))
+ {
+ user->WriteNotice("*** Invalid duration for filter");
+ return CMD_FAILURE;
+ }
reasonindex = 4;
}
else
diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp
index bd4206166..a8dd49e2d 100644
--- a/src/modules/m_repeat.cpp
+++ b/src/modules/m_repeat.cpp
@@ -34,7 +34,7 @@ class ChannelSettings
unsigned int Backlog;
unsigned int Lines;
unsigned int Diff;
- unsigned int Seconds;
+ unsigned long Seconds;
void serialize(std::string& out) const
{
@@ -277,7 +277,10 @@ class RepeatMode : public ParamMode<RepeatMode, SimpleExtItem<ChannelSettings> >
if ((settings.Lines = ConvToNum<unsigned int>(item)) == 0)
return false;
- if ((!stream.GetToken(item)) || ((settings.Seconds = InspIRCd::Duration(item)) == 0))
+ if (!InspIRCd::Duration(item, settings.Seconds))
+ return false;
+
+ if ((!stream.GetToken(item)) || (settings.Seconds == 0))
// Required parameter missing
return false;
diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp
index c1eeb7b9a..77b3bc3aa 100644
--- a/src/modules/m_rline.cpp
+++ b/src/modules/m_rline.cpp
@@ -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
diff --git a/src/modules/m_setidle.cpp b/src/modules/m_setidle.cpp
index 37984030b..8bca7000b 100644
--- a/src/modules/m_setidle.cpp
+++ b/src/modules/m_setidle.cpp
@@ -40,8 +40,8 @@ class CommandSetidle : public SplitCommand
CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE
{
- int idle = InspIRCd::Duration(parameters[0]);
- if (idle < 1)
+ unsigned long idle;
+ if (!InspIRCd::Duration(parameters[0], idle))
{
user->WriteNumeric(ERR_INVALIDIDLETIME, "Invalid idle time.");
return CMD_FAILURE;
diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp
index 91933e7c4..e4fb2c11d 100644
--- a/src/modules/m_shun.cpp
+++ b/src/modules/m_shun.cpp
@@ -90,7 +90,11 @@ class CommandShun : public Command
std::string expr;
if (parameters.size() > 2)
{
- duration = InspIRCd::Duration(parameters[1]);
+ if (!InspIRCd::Duration(parameters[1], duration))
+ {
+ user->WriteNotice("*** Invalid duration for SHUN");
+ return CMD_FAILURE;
+ }
expr = parameters[2];
}
else
diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp
index 8eecd377d..52c250fef 100644
--- a/src/modules/m_svshold.cpp
+++ b/src/modules/m_svshold.cpp
@@ -127,7 +127,12 @@ class CommandSvshold : public Command
if (parameters.size() < 3)
return CMD_FAILURE;
- unsigned long duration = InspIRCd::Duration(parameters[1]);
+ unsigned long duration;
+ if (!InspIRCd::Duration(parameters[1], duration))
+ {
+ user->WriteNotice("*** Invalid duration for SVSHOLD");
+ return CMD_FAILURE;
+ }
SVSHold* r = new SVSHold(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), parameters[0].c_str());
if (ServerInstance->XLines->AddLine(r, user))
diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp
index 058028f61..32b376c79 100644
--- a/src/modules/m_timedbans.cpp
+++ b/src/modules/m_timedbans.cpp
@@ -84,13 +84,13 @@ class CommandTban : public Command
}
TimedBan T;
- unsigned long duration = InspIRCd::Duration(parameters[1]);
- unsigned long expire = duration + ServerInstance->Time();
- if (duration < 1)
+ unsigned long duration;
+ if (!InspIRCd::Duration(parameters[1], duration))
{
user->WriteNotice("Invalid ban time");
return CMD_FAILURE;
}
+ unsigned long expire = duration + ServerInstance->Time();
std::string mask = parameters[2];
bool isextban = ((mask.size() > 2) && (mask[1] == ':'));
if (!isextban && !InspIRCd::IsValidMask(mask))