1
0
mirror of https://github.com/anope/anope.git synced 2026-06-29 07:05:44 +02:00

Fixed /ms set limit none and made db_plain care less about convert exceptions

This commit is contained in:
Adam
2011-02-04 12:37:01 -05:00
parent fb0f7649b4
commit 032c30dd5d
4 changed files with 222 additions and 211 deletions
+1 -1
View File
@@ -485,7 +485,7 @@ class Memo : public Flags<MemoFlag>
struct CoreExport MemoInfo
{
unsigned memomax;
int16 memomax;
std::vector<Memo *> memos;
unsigned GetIndex(Memo *m) const;
+207 -194
View File
File diff suppressed because it is too large Load Diff
+12 -14
View File
@@ -71,7 +71,7 @@ class CommandMSSet : public Command
Anope::string p2 = params.size() > 2 ? params[2] : "";
Anope::string p3 = params.size() > 3 ? params[3] : "";
Anope::string user, chan;
int32 limit;
int16 limit;
NickCore *nc = u->Account();
ChannelInfo *ci = NULL;
bool is_servadmin = u->Account()->HasPriv("memoserv/set-limit");
@@ -115,7 +115,7 @@ class CommandMSSet : public Command
SyntaxError(MemoServ, u, "SET LIMIT", MEMO_SET_LIMIT_SERVADMIN_SYNTAX);
return MOD_CONT;
}
if ((!isdigit(p1[0]) && !p1.equals_ci("NONE")) || (!p2.empty() && !p2.equals_ci("HARD")))
if ((!p1.is_pos_number_only() && !p1.equals_ci("NONE")) || (!p2.empty() && !p2.equals_ci("HARD")))
{
SyntaxError(MemoServ, u, "SET LIMIT", MEMO_SET_LIMIT_SERVADMIN_SYNTAX);
return MOD_CONT;
@@ -134,14 +134,12 @@ class CommandMSSet : public Command
else
nc->UnsetFlag(NI_MEMO_HARDMAX);
}
limit = p1.is_pos_number_only() ? convertTo<int32>(p1) : -1;
if (limit < 0 || limit > 32767)
limit = -1;
try
{
u->SendMessage(MemoServ, MEMO_SET_LIMIT_OVERFLOW, 32767);
limit = 32767;
limit = convertTo<int16>(p1);
}
if (p1.equals_ci("NONE"))
limit = -1;
catch (const CoreException &) { }
}
else
{
@@ -160,7 +158,12 @@ class CommandMSSet : public Command
u->SendMessage(MemoServ, MEMO_SET_YOUR_LIMIT_FORBIDDEN);
return MOD_CONT;
}
limit = p1.is_pos_number_only() ? convertTo<int32>(p1) : -1;
limit = -1;
try
{
limit = convertTo<int16>(p1);
}
catch (const CoreException &) { }
/* The first character is a digit, but we could still go negative
* from overflow... watch out! */
if (limit < 0 || (Config->MSMaxMemos > 0 && static_cast<unsigned>(limit) > Config->MSMaxMemos))
@@ -171,11 +174,6 @@ class CommandMSSet : public Command
u->SendMessage(MemoServ, MEMO_SET_YOUR_LIMIT_TOO_HIGH, Config->MSMaxMemos);
return MOD_CONT;
}
else if (limit > 32767)
{
u->SendMessage(MemoServ, MEMO_SET_LIMIT_OVERFLOW, 32767);
limit = 32767;
}
}
mi->memomax = limit;
if (limit > 0)
+2 -2
View File
@@ -449,7 +449,7 @@ class DBMySQL : public Module
nc->language = r.Get(i, "language");
nc->channelcount = r.Get(i, "channelcount").is_number_only() ? convertTo<int>(r.Get(i, "channelcount")) : 0;
nc->memos.memomax = r.Get(i, "memomax").is_number_only() ? convertTo<int>(r.Get(i, "memomax")) : 20;
nc->memos.memomax = r.Get(i, "memomax").is_number_only() ? convertTo<int16>(r.Get(i, "memomax")) : 20;
}
r = SQL->RunQuery("SELECT * FROM `anope_ns_access`");
@@ -608,7 +608,7 @@ class DBMySQL : public Module
ci->forbidreason = r.Get(i, "forbidreason");
ci->bantype = r.Get(i, "bantype").is_number_only() ? convertTo<int>(r.Get(i, "bantype")) : 2;
ci->entry_message = r.Get(i, "entry_message");
ci->memos.memomax = r.Get(i, "memomax").is_number_only() ? convertTo<int>(r.Get(i, "memomax")) : 20;
ci->memos.memomax = r.Get(i, "memomax").is_number_only() ? convertTo<int16>(r.Get(i, "memomax")) : 20;
ci->capsmin = r.Get(i, "capsmin").is_number_only() ? convertTo<int>(r.Get(i, "capsmin")) : 0;
ci->capspercent = r.Get(i, "capspercent").is_number_only() ? convertTo<int>(r.Get(i, "capspercent")) : 0;
ci->floodlines = r.Get(i, "floodlines").is_number_only() ? convertTo<int>(r.Get(i, "floodlines")) : 0;