mirror of
https://github.com/anope/anope.git
synced 2026-06-26 05:56:39 +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:
@@ -125,7 +125,12 @@ class CommandOSSession : public Command
|
||||
{
|
||||
Anope::string param = params[1];
|
||||
|
||||
unsigned mincount = param.is_pos_number_only() ? convertTo<unsigned>(param) : 0;
|
||||
unsigned mincount = 0;
|
||||
try
|
||||
{
|
||||
mincount = convertTo<unsigned>(param);
|
||||
}
|
||||
catch (const ConvertException &) { }
|
||||
|
||||
if (mincount <= 1)
|
||||
source.Reply(_("Invalid threshold value. It must be a valid integer greater than 1."));
|
||||
@@ -260,7 +265,12 @@ class CommandOSException : public Command
|
||||
else if (expires > 0)
|
||||
expires += Anope::CurTime;
|
||||
|
||||
int limit = !limitstr.empty() && limitstr.is_number_only() ? convertTo<int>(limitstr) : -1;
|
||||
int limit = -1;
|
||||
try
|
||||
{
|
||||
limit = convertTo<int>(limitstr);
|
||||
}
|
||||
catch (const ConvertException &) { }
|
||||
|
||||
if (limit < 0 || limit > static_cast<int>(Config->MaxSessionLimit))
|
||||
{
|
||||
@@ -334,8 +344,13 @@ class CommandOSException : public Command
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
n1 = n1str.is_pos_number_only() ? convertTo<int>(n1str) - 1 : -1;
|
||||
n2 = n2str.is_pos_number_only() ? convertTo<int>(n2str) - 1 : -1;
|
||||
n1 = n2 = -1;
|
||||
try
|
||||
{
|
||||
n1 = convertTo<int>(n1str);
|
||||
n2 = convertTo<int>(n2str);
|
||||
}
|
||||
catch (const ConvertException &) { }
|
||||
|
||||
if (n1 >= 0 && n1 < exceptions.size() && n2 >= 0 && n2 < exceptions.size() && n1 != n2)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user