]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Some minor cleanups
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 19 Sep 2021 09:30:39 +0000 (10:30 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 19 Sep 2021 09:30:39 +0000 (10:30 +0100)
Found by: coverity scan

src/libserver/dkim.c
src/libserver/dns.c
src/libserver/html/html.cxx
src/libserver/milter.c

index 01bea2d56dec6c2e6a075970dab52b630e73e674..762bbaa94f3e8546c73ef74f3e8882de3013de69 100644 (file)
@@ -1117,7 +1117,7 @@ rspamd_create_dkim_context (const gchar *sig,
                        }
                        else {
                                msg_info_dkim ("dkim parse failed: unknown error when parsing %c tag",
-                                               *tag);
+                                               tag ? *tag : '?');
                                return NULL;
                        }
                        break;
@@ -2639,7 +2639,8 @@ rspamd_dkim_check (rspamd_dkim_context_t *ctx,
        }
 
 
-       if (ctx->common.type != RSPAMD_DKIM_ARC_SEAL) {
+       /* Use cached BH for all but arc seal, if it is not NULL we are not in arc seal mode */
+       if (cached_bh != NULL) {
                if (!cached_bh->digest_normal) {
                        /* Copy md_ctx to deal with broken CRLF at the end */
                        cpy_ctx = EVP_MD_CTX_create ();
index 0eff240a66c5802a4a2d4fc78c2c95454122ea6f..eb694a74de93293d678ebc60f422dd1fa49e744e 100644 (file)
@@ -432,6 +432,12 @@ rspamd_dns_server_init (struct upstream *up, guint idx, gpointer ud)
        if (r->cfg) {
                serv = rdns_resolver_add_server (r->r, rspamd_inet_address_to_string (addr),
                                rspamd_inet_address_get_port (addr), 0, r->cfg->dns_io_per_server);
+
+               elt = rspamd_mempool_alloc0 (r->cfg->cfg_pool, sizeof (*elt));
+               elt->server = serv;
+               elt->lib_data = up;
+
+               rspamd_upstream_set_data (up, elt);
        }
        else {
                serv = rdns_resolver_add_server (r->r, rspamd_inet_address_to_string (addr),
@@ -439,12 +445,6 @@ rspamd_dns_server_init (struct upstream *up, guint idx, gpointer ud)
        }
 
        g_assert (serv != NULL);
-
-       elt = rspamd_mempool_alloc0 (r->cfg->cfg_pool, sizeof (*elt));
-       elt->server = serv;
-       elt->lib_data = up;
-
-       rspamd_upstream_set_data (up, elt);
 }
 
 static void
index b9729a71eee43da67447239100240997c4059444..c3485b099614945905c9e2467ab7122ae8c8f653 100644 (file)
@@ -174,22 +174,22 @@ html_check_balance(struct html_content *hc,
                 */
 
                if (hc->all_tags.empty()) {
-                       auto &&vtag = std::make_unique<html_tag>();
+                       hc->all_tags.emplace_back();
+                       auto *vtag = hc->all_tags.back().get();
                        vtag->id = Tag_HTML;
                        vtag->flags = FL_VIRTUAL;
                        vtag->tag_start = 0;
                        vtag->content_offset = 0;
-                       calculate_content_length(vtag.get());
+                       calculate_content_length(vtag);
 
                        if (!hc->root_tag) {
-                               hc->root_tag = vtag.get();
+                               hc->root_tag = vtag;
                        }
                        else {
                                vtag->parent = hc->root_tag;
                        }
 
-                       hc->all_tags.emplace_back(std::move(vtag));
-                       tag->parent = vtag.get();
+                       tag->parent = vtag;
 
                        /* Recursively call with a virtual <html> tag inserted */
                        return html_check_balance(hc, tag, tag_start_offset, tag_end_offset);
index 97e4487940f044a6b2238be4be596922a62e60b6..301c26a1f7b6613f7643e0a3eb00e9bd6eb40bb2 100644 (file)
@@ -908,8 +908,8 @@ rspamd_milter_consume_input (struct rspamd_milter_session *session,
                                         * In general, don't use it for anything but ping checks
                                         */
                                        memset (&http_callbacks, 0, sizeof (http_callbacks));
-                                       http_parser_init (&http_parser, HTTP_REQUEST);
                                        http_parser.data = url;
+                                       http_parser_init (&http_parser, HTTP_REQUEST);
                                        http_callbacks.on_url = rspamd_milter_http_on_url;
                                        http_parser_execute (&http_parser, &http_callbacks,
                                                        priv->parser.buf->str, priv->parser.buf->len);