From f3ec97ee2301397535d6f00d79b7dfce256bf591 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Sun, 15 Sep 2019 15:33:30 +0200 Subject: [PATCH] floodprot (+f): fix issue where 't' was kicking innocent users due to flooding. The 't' action was activated in if no 'r' type was present because the counter was not reset. https://bugs.unrealircd.org/view.php?id=5401 --- src/modules/chanmodes/floodprot.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/modules/chanmodes/floodprot.c b/src/modules/chanmodes/floodprot.c index 3ede66b64..1d0456745 100644 --- a/src/modules/chanmodes/floodprot.c +++ b/src/modules/chanmodes/floodprot.c @@ -1075,23 +1075,23 @@ int check_for_chan_flood(Client *sptr, Channel *chptr, char *text) memberflood = (MemberFlood *)moddata_membership(mb, mdflood).ptr; + if ((TStime() - memberflood->firstmsg) >= chp->per) + { + /* Reset due to moving into a new time slot */ + memberflood->firstmsg = TStime(); + memberflood->nmsg = 1; + memberflood->nmsg_repeat = 1; + if (chp->limit[FLD_REPEAT]) + { + memberflood->lastmsg = gen_floodprot_msghash(text); + memberflood->prevmsg = 0; + } + return 0; /* forget about it.. */ + } + /* Anti-repeat ('r') */ if (chp->limit[FLD_REPEAT]) { - /* if current - firstmsgtime >= mode.per, then reset, - * if nummsg > mode.msgs then kick/ban - */ - if ((TStime() - memberflood->firstmsg) >= chp->per) - { - /* reset */ - memberflood->firstmsg = TStime(); - memberflood->nmsg = 1; - memberflood->nmsg_repeat = 1; - memberflood->lastmsg = gen_floodprot_msghash(text); - memberflood->prevmsg = 0; - return 0; /* forget about it.. */ - } - msghash = gen_floodprot_msghash(text); if (memberflood->lastmsg) {