From: Vsevolod Stakhov Date: Thu, 18 May 2023 19:28:21 +0000 (+0100) Subject: [Minor] Always report multipattern compile error X-Git-Tag: 3.6~114 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d46799f2874622e356fe263aa9fbda99156247f2;p=rspamd.git [Minor] Always report multipattern compile error Issue: #4487 --- diff --git a/src/libmime/message.c b/src/libmime/message.c index ad2cccf92..af8ad0e56 100644 --- a/src/libmime/message.c +++ b/src/libmime/message.c @@ -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) && diff --git a/src/libmime/mime_parser.c b/src/libmime/mime_parser.c index 538c05735..48b946d8f 100644 --- a/src/libmime/mime_parser.c +++ b/src/libmime/mime_parser.c @@ -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)); } diff --git a/src/libserver/url.c b/src/libserver/url.c index 2ae50b95b..824dc05cc 100644 --- a/src/libserver/url.c +++ b/src/libserver/url.c @@ -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; }