summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864>2009-02-11 13:59:56 +0000
committerrburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864>2009-02-11 13:59:56 +0000
commitcdec4027a813a440176caa0225a2cc9b1f152948 (patch)
treeedb33b72e2afb5a186a343cf68420becc7bb3ff8 /src
parentbadcd21abb770c040dd3a842be5e21723cd82e71 (diff)
Finish audit of BotServ commands.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2014 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
-rw-r--r--src/core/bs_badwords.c5
-rw-r--r--src/core/bs_bot.c55
-rw-r--r--src/core/bs_help.c3
-rw-r--r--src/core/bs_info.c2
-rw-r--r--src/core/bs_kick.c30
5 files changed, 61 insertions, 34 deletions
diff --git a/src/core/bs_badwords.c b/src/core/bs_badwords.c
index d51d62517..eab919c2b 100644
--- a/src/core/bs_badwords.c
+++ b/src/core/bs_badwords.c
@@ -239,10 +239,9 @@ class CommandBSBadwords : public Command
{
const char *chan = params[0].c_str();
const char *cmd = params[1].c_str();
- const char *word = params[2].c_str();
+ const char *word = params.size() > 2 ? params[2].c_str() : NULL;
ChannelInfo *ci;
- int need_args = (cmd
- && (!stricmp(cmd, "LIST") || !stricmp(cmd, "CLEAR")));
+ int need_args = (cmd && (!stricmp(cmd, "LIST") || !stricmp(cmd, "CLEAR")));
if (!cmd || (need_args ? 0 : !word))
{
diff --git a/src/core/bs_bot.c b/src/core/bs_bot.c
index 45de014ce..adff0bedb 100644
--- a/src/core/bs_bot.c
+++ b/src/core/bs_bot.c
@@ -22,10 +22,10 @@ class CommandBSBot : public Command
private:
CommandReturn DoAdd(User *u, std::vector<std::string> &params)
{
- const char *nick = params[1].c_str();
- const char *user = params[2].c_str();
- const char *host = params[3].c_str();
- const char *real = params[4].c_str();
+ const char *nick = params[0].c_str();
+ const char *user = params[1].c_str();
+ const char *host = params[2].c_str();
+ const char *real = params[3].c_str();
const char *ch = NULL;
BotInfo *bi;
@@ -138,11 +138,11 @@ class CommandBSBot : public Command
CommandReturn DoChange(User *u, std::vector<std::string> &params)
{
- const char *oldnick = params[1].c_str();
- const char *nick = params[2].c_str();
- const char *user = params[3].c_str();
- const char *host = params[4].c_str();
- const char *real = params[5].c_str();
+ const char *oldnick = params[0].c_str();
+ const char *nick = params[1].c_str();
+ const char *user = params[2].c_str();
+ const char *host = params[3].c_str();
+ const char *real = params[4].c_str();
const char *ch = NULL;
BotInfo *bi;
@@ -311,7 +311,7 @@ class CommandBSBot : public Command
CommandReturn DoDel(User *u, std::vector<std::string> &params)
{
- const char *nick = params[1].c_str();
+ const char *nick = params[0].c_str();
BotInfo *bi;
if (!nick)
@@ -340,19 +340,13 @@ class CommandBSBot : public Command
return MOD_CONT;
}
public:
- CommandBSBot() : Command("BOT", 1, 5)
+ CommandBSBot() : Command("BOT", 1, 6)
{
}
CommandReturn Execute(User *u, std::vector<std::string> &params)
{
- const char *cmd = strtok(NULL, " ");
-
- if (!cmd)
- {
- this->OnSyntaxError(u);
- return MOD_CONT;
- }
+ const char *cmd = params[0].c_str();
if (readonly)
{
@@ -362,14 +356,39 @@ class CommandBSBot : public Command
if (!stricmp(cmd, "ADD"))
{
+ // ADD nick user host real - 5
+ if (params.size() < 5)
+ {
+ this->OnSyntaxError(u);
+ return MOD_CONT;
+ }
+
+ // ADD takes less params than CHANGE, so we need to take 6 if given and append it with a space to 5.
+ if (params.size() >= 6)
+ params[5] = params[5] + " " + params[6];
+
return this->DoAdd(u, params);
}
else if (!stricmp(cmd, "CHANGE"))
{
+ // CHANGE oldn newn user host real - 6
+ if (params.size() < 6)
+ {
+ this->OnSyntaxError(u);
+ return MOD_CONT;
+ }
+
return this->DoChange(u, params);
}
else if (!stricmp(cmd, "DEL"))
{
+ // DEL nick
+ if (params.size() < 1)
+ {
+ this->OnSyntaxError(u);
+ return MOD_CONT;
+ }
+
return this->DoDel(u, params);
}
else
diff --git a/src/core/bs_help.c b/src/core/bs_help.c
index 3506d3acd..181f8e16f 100644
--- a/src/core/bs_help.c
+++ b/src/core/bs_help.c
@@ -24,12 +24,13 @@ class CommandBSHelp : public Command
CommandReturn Execute(User *u, std::vector<std::string> &params)
{
- mod_help_cmd(s_BotServ, u, BOTSERV, params.size() > 0 ? params[0].c_str() : NULL);
+ mod_help_cmd(s_BotServ, u, BOTSERV, params[0].c_str());
return MOD_CONT;
}
void OnSyntaxError(User *u)
{
+ // Abuse syntax error to display general list help.
notice_help(s_BotServ, u, BOT_HELP);
moduleDisplayHelp(4, u);
notice_help(s_BotServ, u, BOT_HELP_FOOTER, BSMinUsers);
diff --git a/src/core/bs_info.c b/src/core/bs_info.c
index 917f3e612..cb1b22c40 100644
--- a/src/core/bs_info.c
+++ b/src/core/bs_info.c
@@ -57,7 +57,7 @@ class CommandBSInfo : public Command
{
BotInfo *bi;
ChannelInfo *ci;
- char *query = strtok(NULL, " ");
+ const char *query = params[0].c_str();
int need_comma = 0, is_servadmin = is_services_admin(u);
char buf[BUFSIZE], *end;
diff --git a/src/core/bs_kick.c b/src/core/bs_kick.c
index 49e187fe1..ad631264c 100644
--- a/src/core/bs_kick.c
+++ b/src/core/bs_kick.c
@@ -30,7 +30,7 @@ class CommandBSKick : public Command
const char *chan = params[0].c_str();
const char *option = params[1].c_str();
const char *value = params[2].c_str();
- const char *ttb = params[3].c_str();
+ const char *ttb = params.size() > 3 ? params[3].c_str() : NULL;
ChannelInfo *ci;
@@ -315,16 +315,24 @@ class CommandBSKick : public Command
bool OnHelp(User *u, const std::string &subcommand)
{
- // XXX: This is not a good way to handle it, we need to accept params for HELP.
- notice_help(s_BotServ, u, BOT_HELP_KICK);
- notice_help(s_BotServ, u, BOT_HELP_KICK_BADWORDS);
- notice_help(s_BotServ, u, BOT_HELP_KICK_BOLDS);
- notice_help(s_BotServ, u, BOT_HELP_KICK_CAPS);
- notice_help(s_BotServ, u, BOT_HELP_KICK_COLORS);
- notice_help(s_BotServ, u, BOT_HELP_KICK_FLOOD);
- notice_help(s_BotServ, u, BOT_HELP_KICK_REPEAT);
- notice_help(s_BotServ, u, BOT_HELP_KICK_REVERSES);
- notice_help(s_BotServ, u, BOT_HELP_KICK_UNDERLINES);
+ if (subcommand == "BADWORDS")
+ notice_help(s_BotServ, u, BOT_HELP_KICK_BADWORDS);
+ else if (subcommand == "BOLDS")
+ notice_help(s_BotServ, u, BOT_HELP_KICK_BOLDS);
+ else if (subcommand == "CAPS")
+ notice_help(s_BotServ, u, BOT_HELP_KICK_CAPS);
+ else if (subcommand == "COLORS")
+ notice_help(s_BotServ, u, BOT_HELP_KICK_COLORS);
+ else if (subcommand == "FLOOD")
+ notice_help(s_BotServ, u, BOT_HELP_KICK_FLOOD);
+ else if (subcommand == "REPEAT")
+ notice_help(s_BotServ, u, BOT_HELP_KICK_REPEAT);
+ else if (subcommand == "REVERSES")
+ notice_help(s_BotServ, u, BOT_HELP_KICK_REVERSES);
+ else if (subcommand == "UNDERLINES")
+ notice_help(s_BotServ, u, BOT_HELP_KICK_UNDERLINES);
+ else
+ notice_help(s_BotServ, u, BOT_HELP_KICK);
return true;
}