From cb59538309ffeb8a4cc2d6c07f4d86353d781744 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Mon, 6 Mar 2017 10:05:30 +0100 Subject: [PATCH] Fix chanmode +f issue where unsetting parts were not effective. For example: '+f [5j#i1,5m#m1,3n]:3' and then '+f [5j#i1,5m]:3' In that case the '3n' was not removed and still effective, as could be seen by a '/MODE #chan'. Reported by The_Myth (#4883). --- src/modules/chanmodes/floodprot.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/modules/chanmodes/floodprot.c b/src/modules/chanmodes/floodprot.c index 2479969343..b2678c7694 100644 --- a/src/modules/chanmodes/floodprot.c +++ b/src/modules/chanmodes/floodprot.c @@ -396,6 +396,14 @@ void *cmodef_put_param(void *fld_in, char *param) fld = MyMallocEx(sizeof(ChanFloodProt)); } + /* always reset settings (l, a, r) */ + for (v=0; v < NUMFLD; v++) + { + fld->l[v] = 0; + fld->a[v] = 0; + fld->r[v] = 0; + } + /* '['<1 letter>[optional: '#'+1 letter],[next..]']'':' */ p2 = strchr(xbuf+1, ']'); @@ -518,6 +526,15 @@ void *cmodef_put_param(void *fld_in, char *param) MyFree(fld); return NULL; } + /* if new 'per xxx seconds' is smaller than current 'per' then reset timers/counters (t, c) */ + if (v < fld->per) + { + for (v=0; v < NUMFLD; v++) + { + fld->t[v] = 0; + fld->c[v] = 0; + } + } fld->per = v; /* Is anything turned on? (to stop things like '+f []:15' */