commit 4a3a6e5: [CritFix] Fix procesing of urls
Vsevolod Stakhov
vsevolod at highsecure.ru
Wed Oct 9 11:28:06 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-10-09 12:24:33 +0100
URL: https://github.com/rspamd/rspamd/commit/4a3a6e52ce533d2697482c0ee0287f7a8be898d6 (HEAD -> master)
[CritFix] Fix procesing of urls
Rspamd tried to process urls by end of match in hyperscan disregarding the fact that
a particular URL has been already processed.
It might cause high memory consumption or crash due to OOM when some particular URLs
being processed.
---
src/libserver/url.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/libserver/url.c b/src/libserver/url.c
index a306ce8c7..69932eab9 100644
--- a/src/libserver/url.c
+++ b/src/libserver/url.c
@@ -2681,6 +2681,13 @@ rspamd_url_trie_callback (struct rspamd_multipattern *mp,
const gchar *pos, *newline_pos = NULL;
struct url_callback_data *cb = context;
+ pos = text + match_pos;
+
+ if (cb->fin > pos) {
+ /* Already seen */
+ return 0;
+ }
+
matcher = &g_array_index (url_scanner->matchers, struct url_matcher,
strnum);
@@ -2689,7 +2696,6 @@ rspamd_url_trie_callback (struct rspamd_multipattern *mp,
return 0;
}
- pos = text + match_pos;
memset (&m, 0, sizeof (m));
m.m_begin = text + match_start;
m.m_len = match_pos - match_start;
@@ -2810,6 +2816,13 @@ rspamd_url_trie_generic_callback_common (struct rspamd_multipattern *mp,
gint rc;
rspamd_mempool_t *pool;
+ pos = text + match_pos;
+
+ if (cb->fin > pos) {
+ /* Already seen */
+ return 0;
+ }
+
matcher = &g_array_index (url_scanner->matchers, struct url_matcher,
strnum);
pool = cb->pool;
@@ -2820,7 +2833,7 @@ rspamd_url_trie_generic_callback_common (struct rspamd_multipattern *mp,
}
memset (&m, 0, sizeof (m));
- pos = text + match_pos;
+
/* Find the next newline after our pos */
if (cb->newlines && cb->newlines->len > 0) {
More information about the Commits
mailing list