mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-12 12:09:03 -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;
|
||||
InspIRCd* Srv;
|
||||
bool nofollow;
|
||||
|
||||
public:
|
||||
ModuleBanRedirect(InspIRCd* Me)
|
||||
: Module::Module(Me), Srv(Me)
|
||||
{
|
||||
re = new BanRedirect(Me);
|
||||
nofollow = false;
|
||||
|
||||
if(!Srv->AddModeWatcher(re))
|
||||
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)
|
||||
{
|
||||
/* 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 */
|
||||
if (chan)
|
||||
{
|
||||
@ -285,7 +293,9 @@ class ModuleBanRedirect : public Module
|
||||
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());
|
||||
nofollow = true;
|
||||
chanrec::JoinUser(Srv, user, redir->targetchan.c_str(), false, "");
|
||||
nofollow = false;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user