From 2da3de60c4e2c0b205544e84d555abdd37eaa3d4 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Sun, 14 Mar 2004 20:16:54 +0000 Subject: [PATCH] - Added conf check for too large spamfilter regex + reason field. Reported by Z3l3zT (#0001648). --- Changes | 2 ++ src/s_conf.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/Changes b/Changes index 839f3d554..912fc1494 100644 --- a/Changes +++ b/Changes @@ -3035,3 +3035,5 @@ seen. gmtime warning still there - Added __attribute__ stuff for ircsprintf() to catch more warnings. - Fixed win32 compile problem. Reported by Troco (#0001644). - Added a missing ',' to the version.c.SH script reported by docco (#0001643) +- Added conf check for too large spamfilter regex + reason field. Reported by + Z3l3zT (#0001648). diff --git a/src/s_conf.c b/src/s_conf.c index fe94c64c7..e317c51e9 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -4878,6 +4878,7 @@ int _test_spamfilter(ConfigFile *conf, ConfigEntry *ce) ConfigEntry *cep; int errors = 0; int got = 0; + char *regex = NULL, *reason = NULL; for (cep = ce->ce_entries; cep; cep = cep->ce_next) { @@ -4895,6 +4896,8 @@ int _test_spamfilter(ConfigFile *conf, ConfigEntry *ce) cep->ce_fileptr->cf_filename, cep->ce_varlinenum, cep->ce_varname); errors++; continue; } + if (!strcmp(cep->ce_varname, "reason")) + reason = cep->ce_vardata; if (!strcmp(cep->ce_varname, "regex") || !strcmp(cep->ce_varname, "action") || !strcmp(cep->ce_varname, "reason") || !strcmp(cep->ce_varname, "ban-time")) continue; @@ -4912,6 +4915,7 @@ int _test_spamfilter(ConfigFile *conf, ConfigEntry *ce) } else if (cep->ce_vardata) { /* Check if it's a valid one */ char *errbuf = unreal_checkregex(cep->ce_vardata,0,0); + regex = cep->ce_vardata; if (errbuf) { config_error("%s:%i: spamfilter::regex contains an invalid regex: %s", @@ -4970,6 +4974,14 @@ int _test_spamfilter(ConfigFile *conf, ConfigEntry *ce) } } + if (regex && reason && (strlen(regex) + strlen(reason) > 505)) + { + config_error("%s:%i: spamfilter block problem: regex + reason field are together over 505 bytes, " + "please choose a shorter regex or reason", + ce->ce_fileptr->cf_filename, ce->ce_varlinenum); + errors++; + } + return errors; }