]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Always report multipattern compile error
authorVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 18 May 2023 19:28:21 +0000 (20:28 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 18 May 2023 19:28:21 +0000 (20:28 +0100)
Issue: #4487

src/libmime/message.c
src/libmime/mime_parser.c
src/libserver/url.c

index ad2cccf929ad6656dc6da67ea7a59219f9ad9743..af8ad0e566d4fe87112900a6932b1633a894b1ba 100644 (file)
@@ -666,7 +666,14 @@ rspamd_check_gtube (struct rspamd_task *task, struct rspamd_mime_text_part *part
                                gtube_pattern_no_action,
                                RSPAMD_MULTIPATTERN_DEFAULT);
 
-               g_assert (rspamd_multipattern_compile (gtube_matcher, NULL));
+               GError *err = NULL;
+               rspamd_multipattern_compile (gtube_matcher, &err);
+
+               if (err != NULL) {
+                       /* It will be expensive, but I don't care, still better than to abort */
+                       msg_err ("cannot compile gtube matcher: %s", err->message);
+                       g_error_free (err);
+               }
        }
 
        if (part->utf_content.len >= sizeof (gtube_pattern_reject) &&
index 538c0573578f781f894eeb5cec70bd41c37e9ab0..48b946d8f018dcd1f3a174486464dfd73ef89c48 100644 (file)
@@ -167,7 +167,13 @@ rspamd_mime_parser_init_lib (void)
        g_assert (lib_ctx->mp_boundary != NULL);
        rspamd_multipattern_add_pattern (lib_ctx->mp_boundary, "\r--", 0);
        rspamd_multipattern_add_pattern (lib_ctx->mp_boundary, "\n--", 0);
-       g_assert (rspamd_multipattern_compile (lib_ctx->mp_boundary, NULL));
+
+       GError *err = NULL;
+       if (!rspamd_multipattern_compile (lib_ctx->mp_boundary, &err)) {
+               msg_err ("fatal error: cannot compile multipattern for mime parser boundaries: %e", err);
+               g_error_free (err);
+               g_abort();
+       }
        ottery_rand_bytes (lib_ctx->hkey, sizeof (lib_ctx->hkey));
 }
 
index 2ae50b95b9d5ee0605ccae41259357fcd5d4737b..824dc05cc1b8a40dcf369169c6e958e18a875bd8 100644 (file)
@@ -630,7 +630,7 @@ rspamd_url_init (const gchar *tld_file)
        if (url_scanner->search_trie_full) {
                if (!rspamd_multipattern_compile (url_scanner->search_trie_full, &err)) {
                        msg_err ("cannot compile tld patterns, url matching will be "
-                                        "broken completely: %e", err);
+                                        "incomplete: %e", err);
                        g_error_free (err);
                        ret = FALSE;
                }