From 4007ad9164bd7f41ca615af2fa55de25ddfdd69c Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 1 Mar 2026 15:10:03 +0000 Subject: Store users by uuid in the messageflood counter map. This prevents weird behaviour caused by address reuse. Reported by @progval. --- src/modules/m_messageflood.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/modules/m_messageflood.cpp') diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index 2b22d5e29..31099083d 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -51,7 +51,7 @@ struct MsgFloodData final class MsgFloodSettings final { private: - using CounterMap = insp::flat_map; + using CounterMap = insp::flat_map; CounterMap counters; public: @@ -71,7 +71,7 @@ public: { auto it = Find(who); if (it == counters.end()) - it = counters.emplace(who, MsgFloodData(period)).first; + it = counters.emplace(who->uuid, MsgFloodData(period)).first; it->second.messages += weight; return (it->second.messages >= this->messages); @@ -79,10 +79,9 @@ public: void Clear(User* who) { - counters.erase(who); + counters.erase(who->uuid); } - CounterMap::iterator Find(User* who) { auto found = false; @@ -93,7 +92,7 @@ public: it = counters.erase(it); else { - if (it->first == who) + if (it->first == who->uuid) { found = true; ret = it; -- cgit v1.3.1-10-gc9f91