aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-10 17:17:09 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-10 17:17:09 +0100
commit6e31344466e2558a99cd46bb29abaa37e1faffc6 (patch)
treeae51cd2a56c252d6f0df6755b76719fe121e81e3
parentc4d3eb4af41a17cf28cb4fbb171d9b70d98259b5 (diff)
downloadrspamd-6e31344466e2558a99cd46bb29abaa37e1faffc6.tar.gz
rspamd-6e31344466e2558a99cd46bb29abaa37e1faffc6.zip
[Minor] Fix compile warnings
-rw-r--r--contrib/lua-lpeg/lptypes.h2
-rw-r--r--contrib/lua-lpeg/lpvm.c3
-rw-r--r--src/controller.c4
-rw-r--r--src/libcryptobox/catena/catena.c6
-rw-r--r--src/libmime/message.c3
-rw-r--r--src/libmime/mime_headers.c4
-rw-r--r--src/libserver/html.c4
-rw-r--r--src/libserver/spf.c2
-rw-r--r--src/libserver/task.c3
-rw-r--r--src/libutil/http_context.c5
-rw-r--r--src/libutil/map.c2
-rw-r--r--src/libutil/printf.c4
-rw-r--r--src/libutil/ssl_util.c3
-rw-r--r--src/libutil/util.c7
-rw-r--r--src/lua/lua_common.c26
-rw-r--r--src/lua/lua_cryptobox.c20
-rw-r--r--src/lua/lua_task.c4
-rw-r--r--src/lua/lua_udp.c3
-rw-r--r--src/lua/lua_worker.c2
-rw-r--r--src/plugins/dkim_check.c3
-rw-r--r--src/plugins/regexp.c4
-rw-r--r--src/rspamadm/lua_repl.c10
22 files changed, 47 insertions, 77 deletions
diff --git a/contrib/lua-lpeg/lptypes.h b/contrib/lua-lpeg/lptypes.h
index 7173d11d3..9dee116cd 100644
--- a/contrib/lua-lpeg/lptypes.h
+++ b/contrib/lua-lpeg/lptypes.h
@@ -154,9 +154,9 @@ typedef struct Charset {
/* Special workaround for luajit */
#if defined(WITH_LUAJIT) && !(defined(_X86_) || defined(__x86_64__) || defined(__i386__))
# define LPEG_LUD_WORKAROUND 1
-#endif
void * lpeg_allocate_mem_low(size_t sz);
void lpeg_free_mem_low(void *p);
+#endif
#endif
diff --git a/contrib/lua-lpeg/lpvm.c b/contrib/lua-lpeg/lpvm.c
index 441712826..4ef424579 100644
--- a/contrib/lua-lpeg/lpvm.c
+++ b/contrib/lua-lpeg/lpvm.c
@@ -17,6 +17,7 @@
#include "lpvm.h"
#include "lpprint.h"
+#ifdef LPEG_LUD_WORKAROUND
#include <sys/mman.h>
#define MAX_PIECES (1u << 2u)
@@ -119,6 +120,8 @@ lpeg_free_mem_low(void *p)
/* No match, unmapped by allocation */
}
+#endif
+
/* initial size for call/backtrack stack */
#if !defined(INITBACK)
#define INITBACK MAXBACK
diff --git a/src/controller.c b/src/controller.c
index 332737724..6e16beb91 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -105,8 +105,8 @@ INIT_LOG_MODULE(controller)
#define COLOR_REJECT "#CB4B4B"
#define COLOR_TOTAL "#9440ED"
-const static ev_tstamp rrd_update_time = 1.0;
-const static guint64 rspamd_controller_ctx_magic = 0xf72697805e6941faULL;
+static const ev_tstamp rrd_update_time = 1.0;
+static const guint64 rspamd_controller_ctx_magic = 0xf72697805e6941faULL;
extern void fuzzy_stat_command (struct rspamd_task *task);
diff --git a/src/libcryptobox/catena/catena.c b/src/libcryptobox/catena/catena.c
index 5b1da3129..0a3ab248a 100644
--- a/src/libcryptobox/catena/catena.c
+++ b/src/libcryptobox/catena/catena.c
@@ -217,8 +217,8 @@ initmem (const uint8_t x[H_LEN], const uint64_t c, uint8_t *r)
}
static inline void
-gamma (const uint8_t garlic, const uint8_t *salt,
- const uint8_t saltlen, uint8_t *r)
+catena_gamma (const uint8_t garlic, const uint8_t *salt,
+ const uint8_t saltlen, uint8_t *r)
{
const uint64_t q = UINT64_C(1) << ((3 * garlic + 3) / 4);
@@ -314,7 +314,7 @@ Flap (const uint8_t x[H_LEN], const uint8_t lambda, const uint8_t garlic,
initmem (x, c, r);
/*Gamma Function*/
- gamma (garlic, salt, saltlen, r);
+ catena_gamma (garlic, salt, saltlen, r);
/* DBH */
for (k = 0; k < lambda; k++) {
diff --git a/src/libmime/message.c b/src/libmime/message.c
index a450f67fe..6a5b4095f 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -224,7 +224,6 @@ rspamd_strip_newlines_parse (struct rspamd_task *task,
struct rspamd_mime_text_part *part)
{
const gchar *p = begin, *c = begin;
- gchar last_c = '\0';
gboolean crlf_added = FALSE;
gboolean url_open_bracket = FALSE;
UChar32 uc;
@@ -276,7 +275,6 @@ rspamd_strip_newlines_parse (struct rspamd_task *task,
case normal_char:
state = seen_cr;
if (p > c) {
- last_c = *(p - 1);
g_byte_array_append (part->utf_stripped_content,
(const guint8 *)c, p - c);
}
@@ -315,7 +313,6 @@ rspamd_strip_newlines_parse (struct rspamd_task *task,
state = seen_lf;
if (p > c) {
- last_c = *(p - 1);
g_byte_array_append (part->utf_stripped_content,
(const guint8 *)c, p - c);
}
diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c
index be3ffc7d0..b024bd7b1 100644
--- a/src/libmime/mime_headers.c
+++ b/src/libmime/mime_headers.c
@@ -1415,11 +1415,11 @@ rspamd_smtp_received_process_from (struct rspamd_task *task,
* - hostname ([ip]:port helo=xxx)
* Maybe more...
*/
- gboolean seen_ip_in_data = FALSE, seen_rdns_in_comment = FALSE;
+ gboolean seen_ip_in_data = FALSE;
if (rpart->head_comment && rpart->head_comment->dlen > 0) {
/* We can have info within comment as part of RFC */
- seen_rdns_in_comment = rspamd_smtp_received_process_host_tcpinfo (
+ rspamd_smtp_received_process_host_tcpinfo (
task, rh,
rpart->head_comment->data, rpart->head_comment->dlen);
}
diff --git a/src/libserver/html.c b/src/libserver/html.c
index 73bf05440..dbbefd10c 100644
--- a/src/libserver/html.c
+++ b/src/libserver/html.c
@@ -573,7 +573,7 @@ rspamd_html_url_is_phished (rspamd_mempool_t *pool,
struct rspamd_url **ptext_url)
{
struct rspamd_url *text_url;
- rspamd_ftok_t phished_tld, disp_tok, href_tok;
+ rspamd_ftok_t disp_tok, href_tok;
gint rc;
goffset url_pos;
gchar *url_str = NULL, *idn_hbuf;
@@ -719,8 +719,6 @@ rspamd_html_url_is_phished (rspamd_mempool_t *pool,
if (!rspamd_url_is_subdomain (&disp_tok, &href_tok)) {
href_url->flags |= RSPAMD_URL_FLAG_PHISHED;
href_url->phished_url = text_url;
- phished_tld.begin = href_tok.begin;
- phished_tld.len = href_tok.len;
text_url->flags |= RSPAMD_URL_FLAG_HTML_DISPLAYED;
}
}
diff --git a/src/libserver/spf.c b/src/libserver/spf.c
index 02041b015..631594808 100644
--- a/src/libserver/spf.c
+++ b/src/libserver/spf.c
@@ -1937,7 +1937,6 @@ parse_spf_record (struct spf_record *rec, struct spf_resolved_element *resolved,
struct spf_addr *addr = NULL;
gboolean res = FALSE;
const gchar *begin;
- struct rspamd_task *task;
gchar t;
g_assert (elt != NULL);
@@ -1947,7 +1946,6 @@ parse_spf_record (struct spf_record *rec, struct spf_resolved_element *resolved,
return TRUE;
}
- task = rec->task;
begin = expand_spf_macro (rec, resolved, elt);
addr = rspamd_spf_new_addr (rec, resolved, begin);
g_assert (addr != NULL);
diff --git a/src/libserver/task.c b/src/libserver/task.c
index e2fcdb2d6..a45342907 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -1059,7 +1059,6 @@ rspamd_task_log_metric_res (struct rspamd_task *task,
GPtrArray *sorted_symbols;
struct rspamd_action *act;
struct rspamd_symbols_group *gr;
- gdouble gr_score;
guint i, j;
khiter_t k;
@@ -1157,7 +1156,7 @@ rspamd_task_log_metric_res (struct rspamd_task *task,
symbuf = rspamd_fstring_sized_new (128);
sorted_symbols = g_ptr_array_sized_new (kh_size (mres->sym_groups));
- kh_foreach (mres->sym_groups, gr, gr_score,{
+ kh_foreach_key (mres->sym_groups, gr,{
if (!(gr->flags & RSPAMD_SYMBOL_GROUP_PUBLIC)) {
if (lf->type == RSPAMD_LOG_PUBLIC_GROUPS) {
continue;
diff --git a/src/libutil/http_context.c b/src/libutil/http_context.c
index 9e2b09798..4d701d0c5 100644
--- a/src/libutil/http_context.c
+++ b/src/libutil/http_context.c
@@ -468,14 +468,11 @@ static void
rspamd_http_keepalive_handler (gint fd, short what, gpointer ud)
{
struct rspamd_http_keepalive_cbdata *cbdata =
- (struct rspamd_http_keepalive_cbdata *)ud;
- struct rspamd_http_context *ctx;
- /*
+ (struct rspamd_http_keepalive_cbdata *)ud;/*
* We can get here if a remote side reported something or it has
* timed out. In both cases we just terminate keepalive connection.
*/
- ctx = cbdata->ctx;
g_queue_delete_link (cbdata->queue, cbdata->link);
msg_debug_http_context ("remove keepalive element %s (%s), %d connections left",
rspamd_inet_address_to_string_pretty (cbdata->conn->keepalive_hash_key->addr),
diff --git a/src/libutil/map.c b/src/libutil/map.c
index 42134921a..123d31c5f 100644
--- a/src/libutil/map.c
+++ b/src/libutil/map.c
@@ -75,9 +75,7 @@ write_http_request (struct http_callback_data *cbd)
{
gchar datebuf[128];
struct rspamd_http_message *msg;
- struct rspamd_map *map;
- map = cbd->map;
msg = rspamd_http_new_message (HTTP_REQUEST);
if (cbd->bk->protocol == MAP_PROTO_HTTPS) {
diff --git a/src/libutil/printf.c b/src/libutil/printf.c
index b0229c73a..972d34e82 100644
--- a/src/libutil/printf.c
+++ b/src/libutil/printf.c
@@ -593,7 +593,7 @@ rspamd_vprintf_common (rspamd_printf_append_func func,
{
gchar zero, numbuf[G_ASCII_DTOSTR_BUF_SIZE], dtoabuf[32], *p, *last;
guchar c;
- const gchar *buf_start = fmt, *fmt_start = NULL;
+ const gchar *buf_start = fmt;
gint d;
gdouble f;
glong written = 0, wr, slen;
@@ -623,8 +623,6 @@ rspamd_vprintf_common (rspamd_printf_append_func func,
written += wr;
}
- fmt_start = fmt;
-
i64 = 0;
ui64 = 0;
diff --git a/src/libutil/ssl_util.c b/src/libutil/ssl_util.c
index 32778f265..6bd7a1986 100644
--- a/src/libutil/ssl_util.c
+++ b/src/libutil/ssl_util.c
@@ -579,7 +579,6 @@ rspamd_ssl_connect_fd (struct rspamd_ssl_connection *conn, gint fd,
gpointer handler_data)
{
gint ret;
- short what;
g_assert (conn != NULL);
@@ -630,11 +629,9 @@ rspamd_ssl_connect_fd (struct rspamd_ssl_connection *conn, gint fd,
if (ret == SSL_ERROR_WANT_READ) {
msg_debug_ssl ("not connected, want read");
- what = EV_READ;
}
else if (ret == SSL_ERROR_WANT_WRITE) {
msg_debug_ssl ("not connected, want write");
- what = EV_WRITE;
}
else {
conn->shut = ssl_shut_unclean;
diff --git a/src/libutil/util.c b/src/libutil/util.c
index f528a321e..55696c212 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -786,7 +786,7 @@ rspamd_pass_signal (GHashTable * workers, gint signo)
#ifndef HAVE_SETPROCTITLE
#ifdef LINUX
-static gchar *title_buffer = 0;
+static gchar *title_buffer = NULL;
static size_t title_buffer_size = 0;
static gchar *title_progname, *title_progname_full;
#endif
@@ -1076,7 +1076,6 @@ setproctitle (const gchar *fmt, ...)
ssize_t written;
if (fmt) {
- ssize_t written2;
va_list ap;
written = rspamd_snprintf (title_buffer,
@@ -1087,13 +1086,11 @@ setproctitle (const gchar *fmt, ...)
return -1;
va_start (ap, fmt);
- written2 = rspamd_vsnprintf (title_buffer + written,
+ rspamd_vsnprintf (title_buffer + written,
title_buffer_size - written,
fmt,
ap);
va_end (ap);
- if (written2 < 0 || (size_t) written2 >= title_buffer_size - written)
- return -1;
}
else {
written = rspamd_snprintf (title_buffer,
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index bbcec4c1c..d68e8e952 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -253,11 +253,9 @@ rspamd_lua_set_path (lua_State *L, const ucl_object_t *cfg_obj, GHashTable *vars
{
const gchar *old_path, *additional_path = NULL;
const ucl_object_t *opts = NULL;
- const gchar *pluginsdir = RSPAMD_PLUGINSDIR,
- *rulesdir = RSPAMD_RULESDIR,
+ const gchar *rulesdir = RSPAMD_RULESDIR,
*lualibdir = RSPAMD_LUALIBDIR,
- *libdir = RSPAMD_LIBDIR,
- *sharedir = RSPAMD_SHAREDIR;
+ *libdir = RSPAMD_LIBDIR;
const gchar *t;
gchar path_buf[PATH_MAX];
@@ -290,16 +288,6 @@ rspamd_lua_set_path (lua_State *L, const ucl_object_t *cfg_obj, GHashTable *vars
}
else {
/* Try environment */
- t = getenv ("SHAREDIR");
- if (t) {
- sharedir = t;
- }
-
- t = getenv ("PLUGINSDIR");
- if (t) {
- pluginsdir = t;
- }
-
t = getenv ("RULESDIR");
if (t) {
rulesdir = t;
@@ -321,16 +309,6 @@ rspamd_lua_set_path (lua_State *L, const ucl_object_t *cfg_obj, GHashTable *vars
}
if (vars) {
- t = g_hash_table_lookup (vars, "PLUGINSDIR");
- if (t) {
- pluginsdir = t;
- }
-
- t = g_hash_table_lookup (vars, "SHAREDIR");
- if (t) {
- sharedir = t;
- }
-
t = g_hash_table_lookup (vars, "RULESDIR");
if (t) {
rulesdir = t;
diff --git a/src/lua/lua_cryptobox.c b/src/lua/lua_cryptobox.c
index 645b2495f..518ae9389 100644
--- a/src/lua/lua_cryptobox.c
+++ b/src/lua/lua_cryptobox.c
@@ -2321,6 +2321,16 @@ lua_cryptobox_gen_dkim_keypair (lua_State *L)
/* Process private key */
rc = i2d_RSAPrivateKey_bio (mbio, r);
+
+ if (rc == 0) {
+ BIO_free (mbio);
+ BN_free (e);
+ RSA_free (r);
+ EVP_PKEY_free (pk);
+
+ return luaL_error (L, "i2d_RSAPrivateKey_bio failed");
+ }
+
len = BIO_get_mem_data (mbio, &data);
b64_data = rspamd_encode_base64 (data, len, -1, &b64_len);
@@ -2334,6 +2344,16 @@ lua_cryptobox_gen_dkim_keypair (lua_State *L)
/* Process public key */
BIO_reset (mbio);
rc = i2d_RSA_PUBKEY_bio (mbio, r);
+
+ if (rc == 0) {
+ BIO_free (mbio);
+ BN_free (e);
+ RSA_free (r);
+ EVP_PKEY_free (pk);
+
+ return luaL_error (L, "i2d_RSA_PUBKEY_bio failed");
+ }
+
len = BIO_get_mem_data (mbio, &data);
b64_data = rspamd_encode_base64 (data, len, -1, &b64_len);
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 2ec6dc29b..b04596ed3 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -3510,6 +3510,7 @@ lua_task_has_from (lua_State *L)
}
lua_pushboolean (L, ret);
+ (void)nrcpt; /* Silence warning */
return 1;
}
@@ -5705,12 +5706,9 @@ lua_task_get_metric_action (lua_State *L)
{
LUA_TRACE_POINT;
struct rspamd_task *task = lua_check_task (L, 1);
- struct rspamd_scan_result *metric_res;
struct rspamd_action *action;
if (task) {
- metric_res = task->result;
-
action = rspamd_check_action_metric (task);
lua_pushstring (L, action->name);
}
diff --git a/src/lua/lua_udp.c b/src/lua/lua_udp.c
index b72108c34..5d1fd8c62 100644
--- a/src/lua/lua_udp.c
+++ b/src/lua/lua_udp.c
@@ -256,11 +256,8 @@ static void
lua_udp_io_handler (gint fd, short what, gpointer p)
{
struct lua_udp_cbdata *cbd = (struct lua_udp_cbdata *)p;
- lua_State *L;
gssize r;
- L = cbd->L;
-
if (what == EV_TIMEOUT) {
if (cbd->sent && cbd->retransmits > 0) {
r = lua_try_send_request (cbd);
diff --git a/src/lua/lua_worker.c b/src/lua/lua_worker.c
index eaf0e02d7..940c6ae4a 100644
--- a/src/lua/lua_worker.c
+++ b/src/lua/lua_worker.c
@@ -261,9 +261,7 @@ lua_worker_control_fin_session (void *ud)
struct rspamd_control_reply rep;
struct rspamd_control_cbdata *cbd = (struct rspamd_control_cbdata *)ud;
rspamd_mempool_t *pool;
- lua_State *L;
- L = cbd->L;
pool = cbd->pool;
memset (&rep, 0, sizeof (rep));
diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c
index 4e5eeda71..410a38309 100644
--- a/src/plugins/dkim_check.c
+++ b/src/plugins/dkim_check.c
@@ -866,7 +866,8 @@ lua_dkim_sign_handler (lua_State *L)
rspamd_mempool_set_variable (task->task_pool, "dkim-signature",
sigs, dkim_module_free_list);
} else {
- (void) g_list_append (sigs, hdr);
+ sigs = g_list_append (sigs, hdr);
+ (void)sigs;
}
}
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index 6841e452a..1b6e0f3f2 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -136,7 +136,7 @@ regexp_module_config (struct rspamd_config *cfg)
struct regexp_module_item *cur_item = NULL;
const ucl_object_t *sec, *value, *elt;
ucl_object_iter_t it = NULL;
- gint res = TRUE, id, nre = 0, nlua = 0, nshots = cfg->default_max_shots;
+ gint res = TRUE, nre = 0, nlua = 0, nshots = cfg->default_max_shots;
if (!rspamd_config_is_module_enabled (cfg, "regexp")) {
return TRUE;
@@ -272,7 +272,7 @@ regexp_module_config (struct rspamd_config *cfg)
}
}
- id = rspamd_symcache_add_symbol (cfg->cache,
+ rspamd_symcache_add_symbol (cfg->cache,
cur_item->symbol,
0,
process_regexp_item,
diff --git a/src/rspamadm/lua_repl.c b/src/rspamadm/lua_repl.c
index b7fd9a4d3..ee22c4868 100644
--- a/src/rspamadm/lua_repl.c
+++ b/src/rspamadm/lua_repl.c
@@ -544,7 +544,7 @@ lua_syntax_highlighter (const char *str, ReplxxColor *colours, int size, void *u
* 3 - line num (int), always 1...
* 4 - column num (must be less than size)
*/
- const gchar *what, *text;
+ const gchar *what;
gsize column, tlen, cur_top, elt_pos;
ReplxxColor elt_color = REPLXX_COLOR_DEFAULT;
@@ -554,7 +554,7 @@ lua_syntax_highlighter (const char *str, ReplxxColor *colours, int size, void *u
lua_rawgeti (L, elt_pos, 1);
what = lua_tostring (L, -1);
lua_rawgeti (L, elt_pos, 2);
- text = lua_tolstring (L, -1, &tlen);
+ lua_tolstring (L, -1, &tlen);
lua_rawgeti (L, elt_pos, 4);
column = lua_tointeger (L, -1);
@@ -782,15 +782,11 @@ rspamadm_lua_handle_exec (struct rspamd_http_connection_entry *conn_ent,
GString *tb;
gint err_idx, i;
lua_State *L;
- struct rspamadm_lua_repl_context *ctx;
- struct rspamadm_lua_repl_session *session = conn_ent->ud;
ucl_object_t *obj, *elt;
const gchar *body;
gsize body_len;
-
- ctx = session->ctx;
-
struct thread_entry *thread = lua_thread_pool_get_for_config (rspamd_main->cfg);
+
L = thread->lua_state;
body = rspamd_http_message_get_body (msg, &body_len);