commit 037260c: [Minor] Use a more strict pattern for tld lookup
Vsevolod Stakhov
vsevolod at highsecure.ru
Thu Mar 19 15:28:06 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-03-19 13:37:31 +0000
URL: https://github.com/rspamd/rspamd/commit/037260cf1cbc50a7e8953704d39cff327002f163
[Minor] Use a more strict pattern for tld lookup
---
src/libutil/multipattern.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/libutil/multipattern.c b/src/libutil/multipattern.c
index f243c1d8a..c348ac6b2 100644
--- a/src/libutil/multipattern.c
+++ b/src/libutil/multipattern.c
@@ -97,13 +97,13 @@ rspamd_multipattern_escape_tld_hyperscan (const gchar *pattern, gsize slen,
gsize *dst_len)
{
gsize len;
- const gchar *p, *prefix;
+ const gchar *p, *prefix, *suffix;
gchar *res;
/*
* We understand the following cases
- * 1) blah -> .blah
- * 2) *.blah -> ..*\\.blah
+ * 1) blah -> .blah\b
+ * 2) *.blah -> ..*\\.blah\b
* 3) ???
*/
@@ -127,9 +127,13 @@ rspamd_multipattern_escape_tld_hyperscan (const gchar *pattern, gsize slen,
len = slen + strlen (prefix);
}
+ suffix = "\\b";
+ len += strlen (suffix);
+
res = g_malloc (len + 1);
slen = rspamd_strlcpy (res, prefix, len + 1);
slen += rspamd_strlcpy (res + slen, p, len + 1 - slen);
+ slen += rspamd_strlcpy (res + slen, suffix, len + 1 - slen);
*dst_len = slen;
More information about the Commits
mailing list