summaryrefslogtreecommitdiff
path: root/modules/protocol/unreal32.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-09-16 21:16:20 -0400
committerAdam <Adam@anope.org>2010-09-16 21:16:20 -0400
commit86c1dab2863f228e92ce7e0bd23ffb17cda0242b (patch)
treed4adf87e720de20eedcd413cc1b7bc9b06247766 /modules/protocol/unreal32.cpp
parentcd1e9f3181234521a2858f73b47f57a22c0dad40 (diff)
Fixed many bugs and crashes
Diffstat (limited to 'modules/protocol/unreal32.cpp')
-rw-r--r--modules/protocol/unreal32.cpp52
1 files changed, 27 insertions, 25 deletions
diff --git a/modules/protocol/unreal32.cpp b/modules/protocol/unreal32.cpp
index 892c4fc57..81bd74aaa 100644
--- a/modules/protocol/unreal32.cpp
+++ b/modules/protocol/unreal32.cpp
@@ -1191,34 +1191,36 @@ bool ChannelModeFlood::IsValid(const Anope::string &value) const
{
if (value.empty())
return false;
- Anope::string rest;
- if (value[0] != ':' && convertTo<unsigned>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<unsigned>(rest.substr(1), rest, false) > 0 && rest.empty())
- return true;
- else
+ try
{
- /* '['<number><1 letter>[optional: '#'+1 letter],[next..]']'':'<number> */
- size_t end_bracket = value.find(']', 1);
- if (end_bracket == Anope::string::npos)
- return false;
- Anope::string xbuf = value.substr(0, end_bracket);
- if (value[end_bracket + 1] != ':')
+ Anope::string rest;
+ if (value[0] != ':' && convertTo<unsigned>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<unsigned>(rest.substr(1), rest, false) > 0 && rest.empty())
+ return true;
+ }
+ catch (const CoreException &) { } // convertTo fail
+
+ /* '['<number><1 letter>[optional: '#'+1 letter],[next..]']'':'<number> */
+ size_t end_bracket = value.find(']', 1);
+ if (end_bracket == Anope::string::npos)
+ return false;
+ Anope::string xbuf = value.substr(0, end_bracket);
+ if (value[end_bracket + 1] != ':')
+ return false;
+ commasepstream args(xbuf.substr(1));
+ Anope::string arg;
+ while (args.GetToken(arg))
+ {
+ /* <number><1 letter>[optional: '#'+1 letter] */
+ size_t p = 0;
+ while (p < arg.length() && isdigit(arg[p]))
+ ++p;
+ if (p == arg.length() || !(arg[p] == 'c' || arg[p] == 'j' || arg[p] == 'k' || arg[p] == 'm' || arg[p] == 'n' || arg[p] == 't'))
+ continue; /* continue instead of break for forward compatability. */
+ int v = arg.substr(0, p).is_number_only() ? convertTo<int>(arg.substr(0, p)) : 0;
+ if (v < 1 || v > 999)
return false;
- commasepstream args(xbuf.substr(1));
- Anope::string arg;
- while (args.GetToken(arg))
- {
- /* <number><1 letter>[optional: '#'+1 letter] */
- size_t p = 0;
- while (p < arg.length() && isdigit(arg[p]))
- ++p;
- if (p == arg.length() || !(arg[p] == 'c' || arg[p] == 'j' || arg[p] == 'k' || arg[p] == 'm' || arg[p] == 'n' || arg[p] == 't'))
- continue; /* continue instead of break for forward compatability. */
- int v = arg.substr(0, p).is_number_only() ? convertTo<int>(arg.substr(0, p)) : 0;
- if (v < 1 || v > 999)
- return false;
- }
- return true;
}
+ return true;
}
static void AddModes()