From: Daniel De Graaf Date: Sat, 25 Sep 2010 21:17:57 +0000 (-0400) Subject: Fix unsafe iteration in m_timedbans X-Git-Tag: v2.0.23~834 X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=7aad2ac848ff19113b64259cebcdd08c4b9fcaab;p=user%2Fhenk%2Fcode%2Finspircd.git Fix unsafe iteration in m_timedbans --- diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index b3b22786e..ad6e8000b 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -133,32 +133,38 @@ class ModuleTimedBans : public Module virtual void OnBackgroundTimer(time_t curtime) { + timedbans expired; for (timedbans::iterator i = TimedBanList.begin(); i != TimedBanList.end();) { if (curtime > i->expire) { - std::string chan = i->channel; - std::string mask = i->mask; - Channel* cr = ServerInstance->FindChan(chan); + expired.push_back(*i); i = TimedBanList.erase(i); - if (cr) - { - std::vector setban; - setban.push_back(chan); - setban.push_back("-b"); - setban.push_back(mask); - - CUList empty; - std::string expiry = "*** Timed ban on " + chan + " expired."; - cr->WriteAllExcept(ServerInstance->FakeClient, true, '@', empty, "NOTICE %s :%s", cr->name.c_str(), expiry.c_str()); - ServerInstance->PI->SendChannelNotice(cr, '@', expiry); - - ServerInstance->SendGlobalMode(setban, ServerInstance->FakeClient); - } } else ++i; } + + for (timedbans::iterator i = expired.begin(); i != expired.end(); i++) + { + std::string chan = i->channel; + std::string mask = i->mask; + Channel* cr = ServerInstance->FindChan(chan); + if (cr) + { + std::vector setban; + setban.push_back(chan); + setban.push_back("-b"); + setban.push_back(mask); + + CUList empty; + std::string expiry = "*** Timed ban on " + chan + " expired."; + cr->WriteAllExcept(ServerInstance->FakeClient, true, '@', empty, "NOTICE %s :%s", cr->name.c_str(), expiry.c_str()); + ServerInstance->PI->SendChannelNotice(cr, '@', expiry); + + ServerInstance->SendGlobalMode(setban, ServerInstance->FakeClient); + } + } } virtual Version GetVersion()