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/cs_access.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/cs_access.cpp')
-rw-r--r-- | modules/core/cs_access.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/modules/core/cs_access.cpp b/modules/core/cs_access.cpp index 3ae5693d3..3811ffbfd 100644 --- a/modules/core/cs_access.cpp +++ b/modules/core/cs_access.cpp @@ -169,7 +169,13 @@ class CommandCSAccess : public Command ChannelInfo *ci = source.ci; Anope::string mask = params[2]; - int level = params[3].is_number_only() ? convertTo<int>(params[3]) : ACCESS_INVALID; + int level = ACCESS_INVALID; + + try + { + level = convertTo<int>(params[3]); + } + catch (const ConvertException &) { } ChanAccess *u_access = ci->GetAccess(u); int16 u_level = u_access ? u_access->level : 0; @@ -536,20 +542,25 @@ class CommandCSLevels : public Command const Anope::string &what = params[2]; const Anope::string &lev = params[3]; - Anope::string error; - int level = (lev.is_number_only() ? convertTo<int>(lev, error, false) : 0); - if (!lev.is_number_only()) - error = "1"; + int level; if (lev.equals_ci("FOUNDER")) - { level = ACCESS_FOUNDER; - error.clear(); + else + { + level = 1; + try + { + level = convertTo<int>(lev); + } + catch (const ConvertException &) + { + this->OnSyntaxError(source, "SET"); + return MOD_CONT; + } } - if (!error.empty()) - this->OnSyntaxError(source, "SET"); - else if (level <= ACCESS_INVALID || level > ACCESS_FOUNDER) + if (level <= ACCESS_INVALID || level > ACCESS_FOUNDER) source.Reply(_("Level must be between %d and %d inclusive."), ACCESS_INVALID + 1, ACCESS_FOUNDER - 1); else { |