diff options
author | Daniel De Graaf <danieldg@inspircd.org> | 2010-09-25 17:17:57 -0400 |
---|---|---|
committer | Daniel De Graaf <danieldg@inspircd.org> | 2010-09-25 17:17:57 -0400 |
commit | 7aad2ac848ff19113b64259cebcdd08c4b9fcaab (patch) | |
tree | 387b4434450188404067d800812f0071547740a6 /src/modules | |
parent | 1e2aa07101e4a777d7e1d1db0544feafd0fe65d9 (diff) |
Fix unsafe iteration in m_timedbans
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_timedbans.cpp | 40 |
1 files changed, 23 insertions, 17 deletions
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<std::string> 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<std::string> 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() |