From b0e469b0bbdbc76692364e1f52ef613cc02a2a06 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 5 May 2007 19:25:09 +0000 Subject: [PATCH] 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 --- src/modules/m_banredirect.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index 1564cef57..6150c5193 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -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; } } -- 2.39.5