]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Stop extracting urls on limit reached
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 23 Dec 2019 17:43:39 +0000 (17:43 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 23 Dec 2019 17:43:39 +0000 (17:43 +0000)
src/libserver/url.c

index 29ea4f633c99a9b3e88f16af1bc0c0e8824c9279..6f5b767c4e27cf5759dec9178ca7f9c3bbf7d281 100644 (file)
@@ -3044,6 +3044,17 @@ rspamd_url_text_part_callback (struct rspamd_url *url, gsize start_offset,
        }
 
        if (target_tbl) {
+               /* Also check max urls */
+               if (cbd->task->cfg && cbd->task->cfg->max_lua_urls > 0) {
+                       if (g_hash_table_size (target_tbl) > cbd->task->cfg->max_lua_urls) {
+                               msg_err_task ("part has too many URLs, we cannot process more: "
+                                                         "%z urls extracted ",
+                                               g_hash_table_size (target_tbl));
+
+                               return FALSE;
+                       }
+               }
+
                if ((existing = g_hash_table_lookup (target_tbl, url)) == NULL) {
                        url->flags |= RSPAMD_URL_FLAG_FROM_TEXT;
                        g_hash_table_insert (target_tbl, url, url);