]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix some more issues
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 18 Sep 2021 14:53:20 +0000 (15:53 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 18 Sep 2021 14:53:20 +0000 (15:53 +0100)
Found by: coverity scan

src/controller.c
src/fuzzy_storage.c
src/libmime/archives.c
src/libserver/cfg_rcl.c
src/rspamd_proxy.c

index a34bb60348bbb39f5ada56ec0f6ff74f8854b3ef..34685b92e53714cd5df6db1b48dc9812ce25d7e2 100644 (file)
@@ -349,6 +349,9 @@ check_uncached:
                        /* We have some unknown salt here */
                        msg_info_ctx ("incorrect key: %z, while %z expected",
                                        key_len, pbkdf->key_len);
+                       g_free (salt_decoded);
+                       g_free (key_decoded); /* valid even if key_decoded == NULL */
+
                        return FALSE;
                }
 
@@ -1357,6 +1360,7 @@ rspamd_controller_handle_graph (
        rspamd_controller_send_ucl (conn_ent, res);
        ucl_object_unref (res);
        g_free (acc);
+       g_free (rrd_result);
 
        return 0;
 }
index d710de17239842db39cd13a1a6e90f0433472e4c..26950bbc94820ce105fd53922787b4d2afb80731 100644 (file)
@@ -1694,6 +1694,7 @@ rspamd_fuzzy_storage_sync (struct rspamd_main *rspamd_main,
        struct rspamd_control_reply rep;
 
        rep.reply.fuzzy_sync.status = 0;
+       rep.type = RSPAMD_CONTROL_FUZZY_SYNC;
 
        if (ctx->backend && worker->index == 0) {
                rspamd_fuzzy_process_updates_queue (ctx, local_db_name, FALSE);
@@ -1734,8 +1735,8 @@ rspamd_fuzzy_storage_reload (struct rspamd_main *rspamd_main,
                        worker->cf->options, rspamd_main->cfg,
                        &err)) == NULL) {
                msg_err ("cannot open backend after reload: %e", err);
-               g_error_free (err);
                rep.reply.reload.status = err->code;
+               g_error_free (err);
        }
        else {
                rep.reply.reload.status = 0;
@@ -1898,10 +1899,16 @@ rspamd_fuzzy_stat_to_ucl (struct rspamd_fuzzy_storage_ctx *ctx, gboolean ip_stat
 static int
 lua_fuzzy_add_pre_handler (lua_State *L)
 {
-       struct rspamd_worker *wrk = *(struct rspamd_worker **)
+       struct rspamd_worker *wrk, **pwrk = (struct rspamd_worker **)
                        rspamd_lua_check_udata (L, 1, "rspamd{worker}");
        struct rspamd_fuzzy_storage_ctx *ctx;
 
+       if (!pwrk) {
+               return luaL_error (L, "invalid arguments, worker + function are expected");
+       }
+
+       wrk = *pwrk;
+
        if (wrk && lua_isfunction (L, 2)) {
                ctx = (struct rspamd_fuzzy_storage_ctx *)wrk->ctx;
 
@@ -1923,10 +1930,16 @@ lua_fuzzy_add_pre_handler (lua_State *L)
 static int
 lua_fuzzy_add_post_handler (lua_State *L)
 {
-       struct rspamd_worker *wrk = *(struct rspamd_worker **)
+       struct rspamd_worker *wrk, **pwrk = (struct rspamd_worker **)
                        rspamd_lua_check_udata (L, 1, "rspamd{worker}");
        struct rspamd_fuzzy_storage_ctx *ctx;
 
+       if (!pwrk) {
+               return luaL_error (L, "invalid arguments, worker + function are expected");
+       }
+
+       wrk = *pwrk;
+
        if (wrk && lua_isfunction (L, 2)) {
                ctx = (struct rspamd_fuzzy_storage_ctx *)wrk->ctx;
 
index 467f9c021c8ea8292f183b7174e75a5c7e4fabe6..8ce767ce125078b1ddc93d8b4350564f357e08aa 100644 (file)
@@ -1410,9 +1410,8 @@ rspamd_7zip_read_archive_props (struct rspamd_task *task,
         * }
         */
 
-       proptype = *p;
-
        if (p != NULL) {
+               proptype = *p;
                SZ_SKIP_BYTES(1);
 
                while (proptype != 0) {
index 47d487ee026bd30f2155938c748ff4c8a9a1fe6b..465503141b241c0eb91332e4a9c7861771742926 100644 (file)
@@ -4163,6 +4163,8 @@ rspamd_rcl_add_doc_by_path (struct rspamd_config *cfg,
                        if (ucl_object_type (cur) != UCL_OBJECT) {
                                msg_err_config ("Bad path while lookup for '%s' at %s",
                                                doc_path, *comp);
+                               g_strfreev (path_components);
+
                                return NULL;
                        }
 
index a7944eecfd5b13bae0eb6cc9c963851051fa772e..13393660e2050469da04f952e228d5ad13c08aa2 100644 (file)
@@ -1544,11 +1544,21 @@ proxy_backend_master_error_handler (struct rspamd_http_connection *conn, GError
                msg_err_session ("cannot connect to upstream, maximum retries "
                                "has been reached: %d", session->retries);
                /* Terminate session immediately */
-               proxy_client_write_error (session, err->code, err->message);
+               if (err) {
+                       proxy_client_write_error(session, err->code, err->message);
+               }
+               else {
+                       proxy_client_write_error(session, 503, "Unknown error after no retries left");
+               }
        }
        else {
                if (!proxy_send_master_message (session)) {
-                       proxy_client_write_error (session, err->code, err->message);
+                       if (err) {
+                               proxy_client_write_error(session, err->code, err->message);
+                       }
+                       else {
+                               proxy_client_write_error(session, 503, "Unknown error on write");
+                       }
                }
                else {
                        msg_info_session ("retry connection to: %s"