1
0
mirror of https://github.com/anope/anope.git synced 2026-07-04 10:03:14 +02:00

Fixed many bugs and crashes

This commit is contained in:
Adam
2010-09-16 21:16:20 -04:00
parent cd1e9f3181
commit 86c1dab286
7 changed files with 45 additions and 45 deletions
+5 -11
View File
@@ -89,12 +89,10 @@ class CoreExport Extensible : public virtual Base
*
* @return Returns true on success, false if otherwise
*/
bool Extend(const Anope::string &key, ExtensibleItemBase *p)
void Extend(const Anope::string &key, ExtensibleItemBase *p)
{
bool Ret = this->Extension_Items.insert(std::make_pair(key, p)).second;
if (!Ret)
delete p;
return Ret;
this->Shrink(key);
this->Extension_Items.insert(std::make_pair(key, p));
}
/** Extend an Extensible class.
@@ -108,13 +106,9 @@ class CoreExport Extensible : public virtual Base
*
* @return Returns true on success, false if otherwise
*/
bool Extend(const Anope::string &key)
void Extend(const Anope::string &key)
{
/* This will only add an item if it doesnt already exist,
* the return value is a std::pair of an iterator to the
* element, and a bool saying if it was actually inserted.
*/
return this->Extend(key, new ExtensibleItemRegular<char *>(NULL));
this->Extend(key, new ExtensibleItemRegular<char *>(NULL));
}
/** Shrink an Extensible class.
+6 -2
View File
@@ -462,7 +462,9 @@ class CommandCSLevels : public Command
Anope::string lev = params[3];
Anope::string error;
int level = convertTo<int>(lev, error, false);
int level = (lev.is_number_only() ? convertTo<int>(lev, error, false) : 0);
if (!lev.is_number_only())
error = "1";
if (lev.equals_ci("FOUNDER"))
{
@@ -475,6 +477,7 @@ class CommandCSLevels : public Command
else if (level <= ACCESS_INVALID || level > ACCESS_FOUNDER)
notice_lang(Config->s_ChanServ, u, CHAN_LEVELS_RANGE, ACCESS_INVALID + 1, ACCESS_FOUNDER - 1);
else
{
for (int i = 0; levelinfo[i].what >= 0; ++i)
{
if (what.equals_ci(levelinfo[i].name))
@@ -493,7 +496,8 @@ class CommandCSLevels : public Command
}
}
notice_lang(Config->s_ChanServ, u, CHAN_LEVELS_UNKNOWN, what.c_str(), Config->s_ChanServ.c_str());
notice_lang(Config->s_ChanServ, u, CHAN_LEVELS_UNKNOWN, what.c_str(), Config->s_ChanServ.c_str());
}
return MOD_CONT;
}
+1 -1
View File
@@ -57,7 +57,7 @@ class CommandCSInfo : public Command
}
/* Should we show all fields? Only for sadmins and identified users */
if (has_auspex && check_access(u, ci, CA_INFO))
if (has_auspex || check_access(u, ci, CA_INFO))
show_all = true;
notice_lang(Config->s_ChanServ, u, CHAN_INFO_HEADER, chan.c_str());
+1 -1
View File
@@ -65,7 +65,7 @@ class CommandCSSetMLock : public Command
if (paramcount >= params.size())
continue;
Anope::string param = params[paramcount];
Anope::string param = params[paramcount++];
ChannelModeParam *cmp = debug_cast<ChannelModeParam *>(cm);
+3 -3
View File
@@ -770,9 +770,9 @@ class DBPlain : public Module
else if (key.equals_ci("MLP"))
{
std::vector<std::pair<Anope::string, Anope::string> > mlp;
for (unsigned j = 0, end = params.size(); j < end; j += 2)
mlp.push_back(std::make_pair(params[j], params[j + 1]));
ci->GetExtRegular("db_mlp", mlp);
mlp.push_back(std::make_pair(params[0], params[1]));
/* For now store mlocked modes in extensible, Anope hasn't yet connected to the IRCd and doesn't know what modes exist */
ci->Extend("db_mlp", new ExtensibleItemRegular<std::vector<std::pair<Anope::string, Anope::string> > >(mlp));
+28 -26
View File
@@ -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] != ':')
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;
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;
}
return true;
}
static void AddModes()
+1 -1
View File
@@ -232,7 +232,7 @@ ChannelModeStatus::~ChannelModeStatus()
*/
bool ChannelModeKey::IsValid(const Anope::string &value) const
{
if (!value.empty() && value.find(':') != Anope::string::npos && value.find(',') != Anope::string::npos)
if (!value.empty() && value.find(':') == Anope::string::npos && value.find(',') == Anope::string::npos)
return true;
return false;