diff options
author | Adam <Adam@anope.org> | 2010-10-13 14:46:53 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-10-13 14:46:53 -0400 |
commit | bc812eeb0335c421c073fcac7c9ab8a96d239024 (patch) | |
tree | 2bf6687eca61adce07e9e369eb71b0673e24e753 /src/misc.cpp | |
parent | 5e9db23883c849077eb48d2b2176163a077f09d4 (diff) |
Fixed a crash if an invalid expiry time is given to a number of commands
Diffstat (limited to 'src/misc.cpp')
-rw-r--r-- | src/misc.cpp | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/src/misc.cpp b/src/misc.cpp index 9e1599bf8..f9a8befc9 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -260,35 +260,39 @@ bool NumberList::InvalidRange(const Anope::string &) */ time_t dotime(const Anope::string &s) { - int amount; - if (s.empty()) return -1; + int amount = 0; Anope::string end; - amount = convertTo<int>(s, end, false); - if (!end.empty()) + + try { - switch (end[0]) + amount = convertTo<int>(s, end, false); + if (!end.empty()) { - case 's': - return amount; - case 'm': - return amount * 60; - case 'h': - return amount * 3600; - case 'd': - return amount * 86400; - case 'w': - return amount * 86400 * 7; - case 'y': - return amount * 86400 * 365; - default: - return -1; + switch (end[0]) + { + case 's': + return amount; + case 'm': + return amount * 60; + case 'h': + return amount * 3600; + case 'd': + return amount * 86400; + case 'w': + return amount * 86400 * 7; + case 'y': + return amount * 86400 * 365; + default: + return -1; + } } } - else - return amount; + catch (const CoreException &) { } + + return amount; } /*************************************************************************/ |