diff options
author | adam- <adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-06-23 16:56:38 +0000 |
---|---|---|
committer | adam- <adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-06-23 16:56:38 +0000 |
commit | dc8f7923f4c9cd685a338072bcc2bb351bf575d9 (patch) | |
tree | cb55529a96b40d43b2646640a06cc248efa76efb /src/modules | |
parent | 59c1a509b4264648a6ef61e96b85f06f735d6dd6 (diff) |
Adds check for using commands on non-registered channels before the
commands are called
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2336 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/cs_appendtopic.c | 9 | ||||
-rw-r--r-- | src/modules/cs_enforce.c | 9 | ||||
-rw-r--r-- | src/modules/cs_tban.c | 8 | ||||
-rw-r--r-- | src/modules/os_info.c | 38 |
4 files changed, 26 insertions, 38 deletions
diff --git a/src/modules/cs_appendtopic.c b/src/modules/cs_appendtopic.c index a314e9d8c..c102e35b1 100644 --- a/src/modules/cs_appendtopic.c +++ b/src/modules/cs_appendtopic.c @@ -62,13 +62,14 @@ class CommandCSAppendTopic : public Command const char *chan = params[0].c_str(); const char *newtopic = params[1].c_str(); char topic[1024]; - Channel *c; + Channel *c = findchan(chan); ChannelInfo *ci; - if (!(c = findchan(chan))) + if (c) + ci = c->ci; + + if (!c) notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); - else if (!(ci = c->ci)) - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name); else if (ci->flags & CI_FORBIDDEN) notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name); else if (!check_access(u, ci, CA_TOPIC)) diff --git a/src/modules/cs_enforce.c b/src/modules/cs_enforce.c index 440366709..22987965e 100644 --- a/src/modules/cs_enforce.c +++ b/src/modules/cs_enforce.c @@ -182,13 +182,14 @@ class CommandCSEnforce : public Command { const char *chan = params[0].c_str(); const char *what = params.size() > 1 ? params[1].c_str() : NULL; - Channel *c; + Channel *c = findchan(chan); ChannelInfo *ci; - if (!(c = findchan(chan))) + if (c) + ci = c->ci; + + if (!c) notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); - else if (!(ci = c->ci)) - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); else if (ci->flags & CI_FORBIDDEN) notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name); else if (!check_access(u, ci, CA_AKICK)) diff --git a/src/modules/cs_tban.c b/src/modules/cs_tban.c index 7dde83f09..43c4395ee 100644 --- a/src/modules/cs_tban.c +++ b/src/modules/cs_tban.c @@ -203,13 +203,9 @@ int delBan(int argc, char **argv) int canBanUser(Channel * c, User * u, User * u2) { - ChannelInfo *ci; + ChannelInfo *ci = c->ci; int ok = 0; - if (!(ci = c->ci)) - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name); - else if (ci->flags & CI_FORBIDDEN) - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, c->name); - else if (!check_access(u, ci, CA_BAN)) + if (!check_access(u, ci, CA_BAN)) notice_lang(s_ChanServ, u, ACCESS_DENIED); else if (ircd->except && is_excepted(ci, u2)) notice_lang(s_ChanServ, u, CHAN_EXCEPTED, u2->nick, ci->name); diff --git a/src/modules/os_info.c b/src/modules/os_info.c index 20dc839e3..efaecead9 100644 --- a/src/modules/os_info.c +++ b/src/modules/os_info.c @@ -146,7 +146,7 @@ class CommandCSOInfo : public Command const char *chan = params[1].c_str(); const char *info = params.size() > 2 ? params[2].c_str() : NULL; char *c; - ChannelInfo *ci = NULL; + ChannelInfo *ci = cs_findchan(chan); if (!info) { @@ -154,19 +154,14 @@ class CommandCSOInfo : public Command return MOD_CONT; } - if ((ci = cs_findchan(chan))) + if (ci->GetExt("os_info", c)) { - if (ci->GetExt("os_info", c)) - { - delete [] c; - ci->Shrink("os_info"); - } - /* Add the module data to the channel */ - ci->Extend("os_info", sstrdup(info)); - me->NoticeLang(s_ChanServ, u, OCINFO_ADD_SUCCESS, chan); + delete [] c; + ci->Shrink("os_info"); } - else - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + /* Add the module data to the channel */ + ci->Extend("os_info", sstrdup(info)); + me->NoticeLang(s_ChanServ, u, OCINFO_ADD_SUCCESS, chan); return MOD_CONT; } @@ -174,21 +169,16 @@ class CommandCSOInfo : public Command CommandReturn DoDel(User *u, std::vector<std::string> ¶ms) { const char *chan = params[1].c_str(); - ChannelInfo *ci = NULL; + ChannelInfo *ci = cs_findchan(chan); - if ((ci = cs_findchan(chan))) + /* Del the module data from the channel */ + char *c; + if (ci->GetExt("os_info", c)) { - /* Del the module data from the channel */ - char *c; - if (ci->GetExt("os_info", c)) - { - delete [] c; - ci->Shrink("os_info"); - } - me->NoticeLang(s_ChanServ, u, OCINFO_DEL_SUCCESS, chan); + delete [] c; + ci->Shrink("os_info"); } - else - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + me->NoticeLang(s_ChanServ, u, OCINFO_DEL_SUCCESS, chan); return MOD_CONT; } |