aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-09-18 15:53:20 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-09-18 15:53:20 +0100
commitcd50e7bd57981b7b7a01eec88ae06968c625b2a7 (patch)
tree9e4a01bea6d6223f58a4980940403dd2fbcb8b9c
parent907cc2eb616124abe41e7c1b525139a54f3cea8f (diff)
downloadrspamd-cd50e7bd57981b7b7a01eec88ae06968c625b2a7.tar.gz
rspamd-cd50e7bd57981b7b7a01eec88ae06968c625b2a7.zip
[Minor] Fix some more issues
Found by: coverity scan
-rw-r--r--src/controller.c4
-rw-r--r--src/fuzzy_storage.c19
-rw-r--r--src/libmime/archives.c3
-rw-r--r--src/libserver/cfg_rcl.c2
-rw-r--r--src/rspamd_proxy.c14
5 files changed, 35 insertions, 7 deletions
diff --git a/src/controller.c b/src/controller.c
index a34bb6034..34685b92e 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -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;
}
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index d710de172..26950bbc9 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -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;
diff --git a/src/libmime/archives.c b/src/libmime/archives.c
index 467f9c021..8ce767ce1 100644
--- a/src/libmime/archives.c
+++ b/src/libmime/archives.c
@@ -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) {
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 47d487ee0..465503141 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -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;
}
diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c
index a7944eecf..13393660e 100644
--- a/src/rspamd_proxy.c
+++ b/src/rspamd_proxy.c
@@ -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"