1
0
mirror of https://github.com/anope/anope.git synced 2026-06-26 13:56:38 +02:00

Fixed a crash if an invalid expiry time is given to a number of commands

This commit is contained in:
Adam
2010-10-13 14:46:53 -04:00
parent 5e9db23883
commit bc812eeb03
+25 -21
View File
@@ -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;
}
/*************************************************************************/