1
0
mirror of https://github.com/anope/anope.git synced 2026-06-28 18:16:38 +02:00

try/catch-ified all instances of convertTo to keep from aborting when a user gives too large or too small a number

This commit is contained in:
Adam
2011-02-04 21:01:33 -05:00
parent faf5f3128f
commit 83556667fd
12 changed files with 236 additions and 144 deletions
+9 -2
View File
@@ -63,7 +63,6 @@ class CommandOSDefcon : public Command
{
User *u = source.u;
const Anope::string &lvl = params[0];
int newLevel = 0;
if (lvl.empty())
{
@@ -71,12 +70,20 @@ class CommandOSDefcon : public Command
defcon_sendlvls(source);
return MOD_CONT;
}
newLevel = lvl.is_number_only() ? convertTo<int>(lvl) : 0;
int newLevel = 0;
try
{
newLevel = convertTo<int>(lvl);
}
catch (const ConvertException &) { }
if (newLevel < 1 || newLevel > 5)
{
this->OnSyntaxError(source, "");
return MOD_CONT;
}
Config->DefConLevel = newLevel;
FOREACH_MOD(I_OnDefconLevel, OnDefconLevel(newLevel));