From 0bc12e552cb7bff2a368b0d49f94fe53caa45f62 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Sun, 28 Aug 2005 16:28:40 +0000 Subject: [PATCH] - Spamfilter: regexes (and reasons) are now more limited in size, this is to combat "I set a spamfilter, but cannot remove it" problems. In practice this means - depending on the length of your spamfilter reason - regexes will be max ~300 characters. Spamfilters set in the .conf can be slightly longer (which still causes them to be truncated in '/stats f', but they don't have to be removed anyway so it's kinda acceptable if it's really needed). This should fix bug #2083, reported by White_Magic. --- Changes | 6 ++++++ src/modules/m_tkl.c | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index fc4b7f70a..39e8eb807 100644 --- a/Changes +++ b/Changes @@ -838,3 +838,9 @@ - Fixed crash with invalid set::network-name (eg: high ascii), reported by galahad (#0002584), now printing an error instead (the network name is limited by the 005 spec). - Added Bulgarian example.bg.conf, translated by Peace. +- Spamfilter: regexes (and reasons) are now more limited in size, this is to combat "I set + a spamfilter, but cannot remove it" problems. In practice this means - depending on the + length of your spamfilter reason - regexes will be max ~300 characters. + Spamfilters set in the .conf can be slightly longer (which still causes them to be + truncated in '/stats f', but they don't have to be removed anyway so it's kinda + acceptable if it's really needed). This should fix bug #2083, reported by White_Magic. diff --git a/src/modules/m_tkl.c b/src/modules/m_tkl.c index 383f62ba6..ee6cb7a35 100644 --- a/src/modules/m_tkl.c +++ b/src/modules/m_tkl.c @@ -690,7 +690,8 @@ char *tkllayer[11] = { }; int targets = 0, action = 0; char targetbuf[64], actionbuf[2]; -char reason[512]; +char reason[512]; +int n; if (IsServer(sptr)) return 0; @@ -783,6 +784,23 @@ char reason[512]; tkllayer[9] = reason; tkllayer[10] = parv[6]; + + /* SPAMFILTER LENGTH CHECK. + * We try to limit it here so '/stats f' output shows ok, output of that is: + * :servername 229 destname F : + * : ^NICKLEN ^ NICKLEN ^check ^check ^check + * And for the other fields (and spacing/etc) we count on max 40 characters. + * We also do >500 instead of >510, since that looks cleaner ;).. so actually we count + * on 50 characters for the rest... -- Syzop + */ + n = strlen(reason) + strlen(parv[6]) + strlen(tkllayer[5]) + (NICKLEN * 2) + 40; + if (n > 500) + { + sendnotice(sptr, "Sorry, spamfilter too long. You'll either have to trim down the " + "reason or the regex (exceeded by %d bytes)", n - 500); + return 0; + } + if (whattodo == 0) {