1
0
mirror of https://github.com/anope/anope.git synced 2026-06-28 05:36: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
+10 -20
View File
@@ -57,30 +57,20 @@ class CommandNSList : public Command
if (pattern[0] == '#')
{
Anope::string tmp = myStrGetToken(pattern.substr(1), '-', 0); /* Read FROM out */
if (tmp.empty())
Anope::string n1 = myStrGetToken(pattern.substr(1), '-', 0), /* Read FROM out */
n2 = myStrGetToken(pattern, '-', 1);
try
{
from = convertTo<int>(n1);
to = convertTo<int>(n2);
}
catch (const ConvertException &)
{
source.Reply(LanguageString::LIST_INCORRECT_RANGE);
return MOD_CONT;
}
if (!tmp.is_number_only())
{
source.Reply(LanguageString::LIST_INCORRECT_RANGE);
return MOD_CONT;
}
from = convertTo<int>(tmp);
tmp = myStrGetTokenRemainder(pattern, '-', 1); /* Read TO out */
if (tmp.empty())
{
source.Reply(LanguageString::LIST_INCORRECT_RANGE);
return MOD_CONT;
}
if (!tmp.is_number_only())
{
source.Reply(LanguageString::LIST_INCORRECT_RANGE);
return MOD_CONT;
}
to = convertTo<int>(tmp);
pattern = "*";
}