diff options
author | Adam <Adam@anope.org> | 2011-02-04 21:01:33 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-02-04 21:01:33 -0500 |
commit | 83556667fd7c9e780e2a67de68d3e2bda74a60ef (patch) | |
tree | 8ceed12d405da35841cbf376c47172bba3e9cb3f /modules/core/os_session.cpp | |
parent | faf5f3128f030f13cdd92ab5a46bfd116a083e87 (diff) |
try/catch-ified all instances of convertTo to keep from aborting when a user gives too large or too small a number
Diffstat (limited to 'modules/core/os_session.cpp')
-rw-r--r-- | modules/core/os_session.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/modules/core/os_session.cpp b/modules/core/os_session.cpp index dd10c2cae..835607f45 100644 --- a/modules/core/os_session.cpp +++ b/modules/core/os_session.cpp @@ -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) { |