mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-04 14:33:14 +02:00
Added check to detect broad /spamfilter masks
This commit is contained in:
@@ -3014,3 +3014,6 @@ seen. gmtime warning still there
|
||||
*** RC2fix release ***
|
||||
- spamfilter.conf: fixed fyle sig (was bad!), some minor updates to the rest,
|
||||
added mirc 6.12 exploit sig. Reported by PHANTOm.
|
||||
- Added a check to try and prevent people from adding all-encompassing
|
||||
regexp's in /spamfilter. Thanks to Ville Laurikari for coming up with the
|
||||
method!
|
||||
|
||||
+1
-1
@@ -646,7 +646,7 @@ extern void extban_init(void);
|
||||
extern char *trim_str(char *str, int len);
|
||||
extern char *ban_realhost, *ban_virthost, *ban_ip;
|
||||
extern void join_channel(aChannel *chptr, aClient *cptr, aClient *sptr, int flags);
|
||||
extern char *unreal_checkregex(char *s, int fastsupport);
|
||||
extern char *unreal_checkregex(char *s, int fastsupport, int check_broadness);
|
||||
extern int banact_stringtoval(char *s);
|
||||
extern char *banact_valtostring(int val);
|
||||
extern int banact_chartoval(char c);
|
||||
|
||||
+1
-1
@@ -563,7 +563,7 @@ char targetbuf[64], actionbuf[2];
|
||||
actionbuf[1] = '\0';
|
||||
|
||||
/* now check the regex... */
|
||||
p = unreal_checkregex(parv[6],0);
|
||||
p = unreal_checkregex(parv[6],0,1);
|
||||
if (p)
|
||||
{
|
||||
sendto_one(sptr, ":%s NOTICE %s :Error in regex '%s': %s",
|
||||
|
||||
+2
-2
@@ -4681,7 +4681,7 @@ int _test_badword(ConfigFile *conf, ConfigEntry *ce) {
|
||||
}
|
||||
else
|
||||
{
|
||||
char *errbuf = unreal_checkregex(word->ce_vardata,1);
|
||||
char *errbuf = unreal_checkregex(word->ce_vardata,1,0);
|
||||
if (errbuf)
|
||||
{
|
||||
config_error("%s:%i: badword::%s contains an invalid regex: %s",
|
||||
@@ -4836,7 +4836,7 @@ int _test_spamfilter(ConfigFile *conf, ConfigEntry *ce)
|
||||
errors++;
|
||||
} else if (cep->ce_vardata) {
|
||||
/* Check if it's a valid one */
|
||||
char *errbuf = unreal_checkregex(cep->ce_vardata,0);
|
||||
char *errbuf = unreal_checkregex(cep->ce_vardata,0,0);
|
||||
if (errbuf)
|
||||
{
|
||||
config_error("%s:%i: spamfilter::regex contains an invalid regex: %s",
|
||||
|
||||
+9
-1
@@ -775,8 +775,10 @@ char *p;
|
||||
/** Checks if the specified regex (or fast badwords) is valid.
|
||||
* returns NULL in case of success [!],
|
||||
* pointer to buffer with error message otherwise
|
||||
* if check_broadness is 1, the function will attempt to determine
|
||||
* if the given regex string is too broad (i.e. matches everything)
|
||||
*/
|
||||
char *unreal_checkregex(char *s, int fastsupport)
|
||||
char *unreal_checkregex(char *s, int fastsupport, int check_broadness)
|
||||
{
|
||||
int errorcode, errorbufsize, regex=0;
|
||||
char *errtmp, *tmp;
|
||||
@@ -810,6 +812,12 @@ Ilovegotos:
|
||||
regfree(&expr);
|
||||
return errorbuf;
|
||||
}
|
||||
if (check_broadness && !regexec(&expr, "", 0, NULL, 0))
|
||||
{
|
||||
strncpyzt(errorbuf, "Regular expression is too broad", sizeof(errorbuf));
|
||||
regfree(&expr);
|
||||
return errorbuf;
|
||||
}
|
||||
regfree(&expr);
|
||||
}
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user