summaryrefslogtreecommitdiff
path: root/modules/commands
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-09-21 11:21:38 -0400
committerAdam <Adam@anope.org>2013-09-27 19:11:02 -0400
commitdf3c0b7b52066698a97b34edf5352cf344e991ac (patch)
treefb3f2384e8863e9fcb86581ed56516b4c2233b48 /modules/commands
parent45702992ac8c0d36bd0a7eba1580d9cf8a364d74 (diff)
Fix various commands to properly report a given expiry time is invalid
Diffstat (limited to 'modules/commands')
-rw-r--r--modules/commands/bs_set.cpp16
-rw-r--r--modules/commands/cs_ban.cpp5
-rw-r--r--modules/commands/cs_suspend.cpp7
-rw-r--r--modules/commands/ns_suspend.cpp7
-rw-r--r--modules/commands/os_forbid.cpp7
-rw-r--r--modules/commands/os_ignore.cpp6
6 files changed, 43 insertions, 5 deletions
diff --git a/modules/commands/bs_set.cpp b/modules/commands/bs_set.cpp
index 49ebfa360..1e320be40 100644
--- a/modules/commands/bs_set.cpp
+++ b/modules/commands/bs_set.cpp
@@ -104,7 +104,21 @@ class CommandBSSetBanExpire : public Command
return;
}
- ci->banexpire = Anope::DoTime(arg);
+ time_t t = Anope::DoTime(arg);
+ if (t == -1)
+ {
+ source.Reply(BAD_EXPIRY_TIME);
+ return;
+ }
+
+ /* cap at 1 day */
+ if (t > 86400)
+ {
+ source.Reply(_("Ban expiry may not be longer than 1 day."));
+ return;
+ }
+
+ ci->banexpire = t;
bool override = !access.HasPriv("SET");
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to change banexpire to " << ci->banexpire;
diff --git a/modules/commands/cs_ban.cpp b/modules/commands/cs_ban.cpp
index 8d1c05336..bb41658de 100644
--- a/modules/commands/cs_ban.cpp
+++ b/modules/commands/cs_ban.cpp
@@ -69,6 +69,11 @@ class CommandCSBan : public Command
if (params[1][0] == '+')
{
ban_time = Anope::DoTime(params[1]);
+ if (ban_time == -1)
+ {
+ source.Reply(BAD_EXPIRY_TIME);
+ return;
+ }
if (params.size() < 3)
{
this->SendSyntax(source);
diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp
index 241d28453..bc122d048 100644
--- a/modules/commands/cs_suspend.cpp
+++ b/modules/commands/cs_suspend.cpp
@@ -73,7 +73,14 @@ class CommandCSSuspend : public Command
expiry.clear();
}
else
+ {
expiry_secs = Anope::DoTime(expiry);
+ if (expiry_secs == -1)
+ {
+ source.Reply(BAD_EXPIRY_TIME);
+ return;
+ }
+ }
if (Anope::ReadOnly)
source.Reply(READ_ONLY_MODE);
diff --git a/modules/commands/ns_suspend.cpp b/modules/commands/ns_suspend.cpp
index 1037cfa88..ac4fdfaed 100644
--- a/modules/commands/ns_suspend.cpp
+++ b/modules/commands/ns_suspend.cpp
@@ -79,7 +79,14 @@ class CommandNSSuspend : public Command
expiry.clear();
}
else
+ {
expiry_secs = Anope::DoTime(expiry);
+ if (expiry_secs == -1)
+ {
+ source.Reply(BAD_EXPIRY_TIME);
+ return;
+ }
+ }
NickAlias *na = NickAlias::Find(nick);
if (!na)
diff --git a/modules/commands/os_forbid.cpp b/modules/commands/os_forbid.cpp
index ec498a3ba..1cec143e9 100644
--- a/modules/commands/os_forbid.cpp
+++ b/modules/commands/os_forbid.cpp
@@ -137,7 +137,12 @@ class CommandOSForbid : public Command
if (!expiry.empty())
{
expiryt = Anope::DoTime(expiry);
- if (expiryt)
+ if (expiryt == -1)
+ {
+ source.Reply(BAD_EXPIRY_TIME);
+ return;
+ }
+ else if (expiryt)
expiryt += Anope::CurTime;
}
diff --git a/modules/commands/os_ignore.cpp b/modules/commands/os_ignore.cpp
index 4cdb26a74..3bd909c49 100644
--- a/modules/commands/os_ignore.cpp
+++ b/modules/commands/os_ignore.cpp
@@ -164,7 +164,7 @@ class CommandOSIgnore : public Command
if (t <= -1)
{
- source.Reply(_("You have to enter a valid number as time."));
+ source.Reply(BAD_EXPIRY_TIME);
return;
}
@@ -176,8 +176,8 @@ class CommandOSIgnore : public Command
}
else
{
- source.Reply(_("\002%s\002 will now be ignored for \002%s\002."), nick.c_str(), time.c_str());
- Log(LOG_ADMIN, source, this) << "to add an ignore on " << nick << " for " << time;
+ source.Reply(_("\002%s\002 will now be ignored for \002%s\002."), nick.c_str(), Anope::Duration(t, source.GetAccount()).c_str());
+ Log(LOG_ADMIN, source, this) << "to add an ignore on " << nick << " for " << Anope::Duration(t, source.GetAccount());
}
}