mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-13 12:39:05 -04:00
Fix for crash found by potter if you set up two redirects in two channels to forward the user back and forth between the two in a loop.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6889 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
80845a3a69
commit
b0e469b0bb
@ -187,12 +187,14 @@ class ModuleBanRedirect : public Module
|
|||||||
{
|
{
|
||||||
BanRedirect* re;
|
BanRedirect* re;
|
||||||
InspIRCd* Srv;
|
InspIRCd* Srv;
|
||||||
|
bool nofollow;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ModuleBanRedirect(InspIRCd* Me)
|
ModuleBanRedirect(InspIRCd* Me)
|
||||||
: Module::Module(Me), Srv(Me)
|
: Module::Module(Me), Srv(Me)
|
||||||
{
|
{
|
||||||
re = new BanRedirect(Me);
|
re = new BanRedirect(Me);
|
||||||
|
nofollow = false;
|
||||||
|
|
||||||
if(!Srv->AddModeWatcher(re))
|
if(!Srv->AddModeWatcher(re))
|
||||||
throw ModuleException("Could not add mode watcher");
|
throw ModuleException("Could not add mode watcher");
|
||||||
@ -255,6 +257,12 @@ class ModuleBanRedirect : public Module
|
|||||||
|
|
||||||
virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs)
|
virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs)
|
||||||
{
|
{
|
||||||
|
/* This prevents recursion when a user sets multiple ban redirects in a chain
|
||||||
|
* (thanks Potter)
|
||||||
|
*/
|
||||||
|
if (nofollow)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* Return 1 to prevent the join, 0 to allow it */
|
/* Return 1 to prevent the join, 0 to allow it */
|
||||||
if (chan)
|
if (chan)
|
||||||
{
|
{
|
||||||
@ -285,7 +293,9 @@ class ModuleBanRedirect : public Module
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
user->WriteServ("470 %s :You are banned from %s. You are being automatically redirected to %s", user->nick, chan->name, redir->targetchan.c_str());
|
user->WriteServ("470 %s :You are banned from %s. You are being automatically redirected to %s", user->nick, chan->name, redir->targetchan.c_str());
|
||||||
|
nofollow = true;
|
||||||
chanrec::JoinUser(Srv, user, redir->targetchan.c_str(), false, "");
|
chanrec::JoinUser(Srv, user, redir->targetchan.c_str(), false, "");
|
||||||
|
nofollow = false;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user