summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--src/misc.cpp5
7 files changed, 47 insertions, 6 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());
}
}
diff --git a/src/misc.cpp b/src/misc.cpp
index c9e18dc66..fe0c49158 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -294,7 +294,10 @@ time_t Anope::DoTime(const Anope::string &s)
}
}
}
- catch (const ConvertException &) { }
+ catch (const ConvertException &)
+ {
+ amount = -1;
+ }
return amount;
}