const gchar *action = "no action";
gchar scorebuf[32];
GString *symbuf, *folded_symbuf, *added_headers;
- gint act;
+ gint act = 0;
goffset headers_pos;
gdouble score = 0.0, required_score = 0.0;
gboolean is_spam = FALSE;
{
const gchar *salt, *hash;
gchar *salt_decoded, *key_decoded;
- gsize salt_len, key_len;
+ gsize salt_len = 0, key_len = 0;
gboolean ret = TRUE;
guchar *local_key;
rspamd_ftok_t *cache;
rspamd_fuzzy_process_command (struct fuzzy_session *session)
{
gboolean encrypted = FALSE, is_shingle = FALSE;
- struct rspamd_fuzzy_cmd *cmd;
+ struct rspamd_fuzzy_cmd *cmd = NULL;
struct rspamd_fuzzy_reply result;
struct fuzzy_peer_cmd *up_cmd;
struct fuzzy_peer_request *up_req;
struct fuzzy_key_stat *ip_stat = NULL;
rspamd_inet_addr_t *naddr;
gpointer ptr;
- gsize up_len;
+ gsize up_len = 0;
switch (session->cmd_type) {
case CMD_NORMAL:
break;
}
+ if (G_UNLIKELY (cmd == NULL || up_len == 0)) {
+ result.value = 500;
+ result.prob = 0.0;
+ goto reply;
+ }
+
if (session->ctx->encrypted_only && !encrypted) {
/* Do not accept unencrypted commands */
result.value = 403;
SOCK_STREAM /* TCP socket */
};
-const static gdouble default_max_time = 1.0;
-const static gdouble default_recompile_time = 60.0;
+static const gdouble default_max_time = 1.0;
+static const gdouble default_recompile_time = 60.0;
/*
* Worker's context
#define POLY1305_NOINLINE __declspec(noinline)
#elif defined(__GNUC__)
+ #pragma GCC system_header
#if defined(__SIZEOF_INT128__)
typedef unsigned __int128 uint128_t;
#else
gint state = 0, hlen;
gboolean found = FALSE;
GArray *to_sign;
- struct rspamd_dkim_sign_chunk chunk, *elt;
+ struct rspamd_dkim_sign_chunk chunk, *elt = NULL;
gint i;
/* This process is very similar to raw headers processing */
}
}
- if (elt->append_crlf) {
+ if (elt && elt->append_crlf) {
rspamd_dkim_signature_update (ctx, elt->begin, elt->len + 1);
}
else {
}
/* Sync virtual symbols */
for (i = 0; i < cache->items_by_id->len; i ++) {
+ item = g_ptr_array_index (cache->items_by_id, i);
+
if (item->parent != -1) {
parent = g_ptr_array_index (cache->items_by_id, item->parent);
- item->avg_time = parent->avg_time;
- item->avg_counter = parent->avg_counter;
+
+ if (parent) {
+ item->avg_time = parent->avg_time;
+ item->avg_counter = parent->avg_counter;
+ }
}
}
struct in_addr in4;
struct in6_addr in6;
gboolean ret = FALSE, check_num = TRUE;
- guint32 n, dots, t, i, shift, nshift;
+ guint32 n, dots, t = 0, i = 0, shift, nshift;
p = uri->host;
end = p + uri->hostlen;
#include "rspamd_control.h"
#ifdef WITH_GPERF_TOOLS
-#include <google/profiler.h>
+#include <gperftools/profiler.h>
#endif
/* sys/resource.h */
#ifdef HAVE_SYS_RESOURCE_H
#ifdef HAVE_GRP_H
#include <grp.h>
#endif
+#ifdef HAVE_LIBUTIL_H
+#include <libutil.h>
+#endif
/**
* Return worker's control structure by its type
struct rspamd_stat_ctx *st_ctx;
struct rspamd_classifier *cl;
const ucl_object_t *obj, *elt1, *elt2;
- struct metric_result *mres;
+ struct metric_result *mres = NULL;
struct rspamd_task **ptask;
lua_State *L;
GString *tb;
task->flags &= ~(RSPAMD_TASK_FLAG_LEARN_HAM |
RSPAMD_TASK_FLAG_LEARN_SPAM);
}
- else {
+ else if (mres != NULL) {
if (task->flags & RSPAMD_TASK_FLAG_LEARN_HAM) {
msg_info_task ("<%s>: autolearn ham for classifier "
"'%s' as message's "
rspamd_aio_cb cb,
gpointer ud)
{
- struct io_cbdata *cbdata;
gint r = -1;
if (ctx->has_aio) {
#ifdef LINUX
struct iocb *iocb[1];
+ struct io_cbdata *cbdata;
cbdata = g_slice_alloc (sizeof (struct io_cbdata));
cbdata->cb = cb;
}
else {
/* Blocking variant */
+ goto blocking;
blocking:
#ifdef _LARGEFILE64_SOURCE
r = lseek64 (fd, offset, SEEK_SET);
rspamd_aio_cb cb,
gpointer ud)
{
- struct io_cbdata *cbdata;
gint r = -1;
if (ctx->has_aio) {
#ifdef LINUX
struct iocb *iocb[1];
+ struct io_cbdata *cbdata;
cbdata = g_slice_alloc (sizeof (struct io_cbdata));
cbdata->cb = cb;
}
else {
/* Blocking variant */
+ goto blocking;
blocking:
#ifdef _LARGEFILE64_SOURCE
r = lseek64 (fd, offset, SEEK_SET);
end = header + strlen (header);
}
-#if (NGX_SUPPRESS_WARN)
day = 32;
year = 2038;
-#endif
for (p = header; p < end; p++) {
if (*p == ',') {
struct rspamd_http_header *hdr;
struct tm t, *ptm;
gchar datebuf[64], repbuf[512], *pbody;
- gint i, hdrcount, meth_len, preludelen = 0;
- gsize bodylen, enclen;
+ gint i, hdrcount, meth_len = 0, preludelen = 0;
+ gsize bodylen, enclen = 0;
rspamd_fstring_t *buf;
gboolean encrypted = FALSE;
gchar *b32_key, *b32_id;
enclen);
}
else {
- rspamd_printf_fstring (&buf, "HTTP/1.1 %d %V\r\n"
+ meth_len = rspamd_printf_fstring (&buf, "HTTP/1.1 %d %V\r\n"
"Connection: close\r\n"
"Server: %s\r\n"
"Date: %s\r\n"
read_map_file (struct rspamd_map *map, struct file_map_data *data)
{
struct map_cb_data cbdata;
- gchar buf[BUFSIZ], *remain;
+ gchar buf[BUFSIZ], *remain = NULL;
ssize_t r;
gint fd, rlen, tlen;
rspamd_mempool_t *pool = map->pool;
struct rrd_rra_def *rra;
rrd_value_t *scratch;
enum rrd_cf_type cf;
- gdouble last_cdp, cur_cdp;
+ gdouble last_cdp = INFINITY, cur_cdp = INFINITY;
gulong pdp_in_cdp;
rra = &file->rra_def[rra_index];
case RRD_CF_LAST:
default:
scratch[CDP_primary_val].dv = pdp_temp[i];
+ last_cdp = INFINITY;
break;
}
}
const gchar *p, *c;
gboolean first_token = TRUE;
enum {
- fold_before,
+ fold_before = 0,
fold_after
- } fold_type;
+ } fold_type = fold_before;
enum {
- read_token,
+ read_token = 0,
read_quoted,
after_quote,
fold_token,
#include <mach/mach_time.h>
#endif
#ifdef WITH_GPERF_TOOLS
-#include <google/profiler.h>
+#include <gperftools/profiler.h>
#endif
/* poll */
#ifdef HAVE_POLL_H
{
GList *metric_list;
gchar *symbol;
- const gchar *desc;
+ const gchar *desc = NULL;
struct metric *metric;
gdouble *score;
struct rspamd_symbol_def *s;
lua_gettable (L, -2);
if (lua_isstring (L, -1)) {
desc = lua_tostring (L, -1);
- s->description = rspamd_mempool_strdup (cfg->cfg_pool, desc);
}
lua_pop (L, 1);
}
g_hash_table_insert (metric->symbols, symbol, s);
}
+ if (desc) {
+ s->description = rspamd_mempool_strdup (cfg->cfg_pool, desc);
+ }
+
if ((metric_list =
g_hash_table_lookup (cfg->metrics_symbols, symbol)) == NULL) {
metric_list = g_list_prepend (NULL, metric);
gsize datalen)
{
struct rspamd_fuzzy_cmd *cmd;
- struct rspamd_fuzzy_encrypted_cmd *enccmd;
+ struct rspamd_fuzzy_encrypted_cmd *enccmd = NULL;
struct fuzzy_cmd_io *io;
rspamd_cryptobox_hash_state_t st;
io->tag = cmd->tag;
if (rule->peer_key) {
+ g_assert (enccmd != NULL);
fuzzy_encrypt_cmd (rule, &enccmd->hdr, (guchar *) cmd, sizeof (*cmd));
io->io.iov_base = enccmd;
io->io.iov_len = sizeof (*enccmd);
gint
regexp_module_config (struct rspamd_config *cfg)
{
- struct regexp_module_item *cur_item;
+ 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;
const gchar *value, gpointer data,
GError **error);
+static union {
+ gboolean (*func)(const gchar *option_name,
+ const gchar *value, gpointer data,
+ GError **error);
+ const gpointer ptr;
+} rspamadm_parse_ucl_var_un = {
+ .func = &rspamadm_parse_ucl_var
+};
+
static GOptionEntry entries[] = {
{"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
"Enable verbose logging", NULL},
{"list-commands", 'l', 0, G_OPTION_ARG_NONE, &list_commands,
"List available commands", NULL},
- {"var", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer)rspamadm_parse_ucl_var,
+ {"var", 0, 0, G_OPTION_ARG_CALLBACK, &rspamadm_parse_ucl_var_un,
"Redefine UCL variable", NULL},
{"help", 'h', 0, G_OPTION_ARG_NONE, &show_help,
"Show help", NULL},
#include <libutil.h>
#endif
#ifdef WITH_GPERF_TOOLS
-#include <google/profiler.h>
+#include <gperftools/profiler.h>
#endif
-
#ifdef HAVE_STROPS_H
#include <stropts.h>
#endif