aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/client/librspamdclient.c14
-rw-r--r--src/cfg_xml.c20
-rw-r--r--src/diff.c7
-rw-r--r--src/expressions.c8
-rw-r--r--src/kvstorage_config.c4
-rw-r--r--src/kvstorage_file.c18
-rw-r--r--src/kvstorage_server.c5
-rw-r--r--src/message.c4
-rw-r--r--src/protocol.c3
-rw-r--r--src/url.c3
-rw-r--r--src/util.c4
11 files changed, 60 insertions, 30 deletions
diff --git a/lib/client/librspamdclient.c b/lib/client/librspamdclient.c
index 55a9b13dc..dad2a3388 100644
--- a/lib/client/librspamdclient.c
+++ b/lib/client/librspamdclient.c
@@ -323,7 +323,7 @@ static gboolean
parse_rspamd_first_line (struct rspamd_connection *conn, guint len, GError **err)
{
gchar *b = conn->in_buf->str + sizeof("RSPAMD/") - 1, *p, *c;
- guint remain = len - sizeof("RSPAMD/") + 1, state = 0, next_state;
+ guint remain = len - sizeof("RSPAMD/") + 1, state = 0, next_state = 0;
gdouble dver;
p = b;
@@ -401,8 +401,8 @@ static gboolean
parse_rspamd_metric_line (struct rspamd_connection *conn, guint len, GError **err)
{
gchar *b = conn->in_buf->str + sizeof("Metric:") - 1, *p, *c, *err_str;
- guint remain = len - sizeof("Metric:") + 1, state = 0, next_state;
- struct rspamd_metric *new;
+ guint remain = len - sizeof("Metric:") + 1, state = 0, next_state = 0;
+ struct rspamd_metric *new = NULL;
p = b;
@@ -543,8 +543,8 @@ static gboolean
parse_rspamd_symbol_line (struct rspamd_connection *conn, guint len, GError **err)
{
gchar *b = conn->in_buf->str + sizeof("Symbol:") - 1, *p, *c, *err_str, *sym;
- guint remain = len - sizeof("Symbol:") + 1, state = 0, next_state, l;
- struct rspamd_symbol *new;
+ guint remain = len - sizeof("Symbol:") + 1, state = 0, next_state = 0, l;
+ struct rspamd_symbol *new = NULL;
p = b;
while (g_ascii_isspace (*p)) {
@@ -684,7 +684,7 @@ static gboolean
parse_rspamd_action_line (struct rspamd_connection *conn, guint len, GError **err)
{
gchar *b = conn->in_buf->str + sizeof("Action:") - 1, *p, *c, *sym;
- guint remain = len - sizeof("Action:") + 1, state = 0, next_state;
+ guint remain = len - sizeof("Action:") + 1, state = 0, next_state = 0;
p = b;
c = b;
@@ -752,7 +752,7 @@ static gboolean
parse_rspamd_header_line (struct rspamd_connection *conn, guint len, GError **err)
{
gchar *b = conn->in_buf->str, *p, *c, *hname = NULL, *hvalue = NULL;
- guint remain = len, state = 0, next_state;
+ guint remain = len, state = 0, next_state = 0;
p = b;
c = b;
diff --git a/src/cfg_xml.c b/src/cfg_xml.c
index 4b3a7970d..87929f510 100644
--- a/src/cfg_xml.c
+++ b/src/cfg_xml.c
@@ -2097,6 +2097,11 @@ check_module_option (const gchar *mname, const gchar *optname, const gchar *data
GHashTable *module;
gchar *err_str;
struct option_callback_data cd;
+ union {
+ gint i;
+ gdouble d;
+ guint ui;
+ } t;
if (module_options == NULL) {
msg_warn ("no module options registered while checking option %s for module %s", mname, optname);
@@ -2128,39 +2133,44 @@ check_module_option (const gchar *mname, const gchar *optname, const gchar *data
/* Allways OK */
return TRUE;
case MODULE_OPT_TYPE_INT:
- (void)strtol (data, &err_str, 10);
+ t.i = strtol (data, &err_str, 10);
if (*err_str != '\0') {
msg_warn ("non-numeric data for option: '%s' for module: '%s' at position: '%s'", optname, mname, err_str);
return FALSE;
}
+ (void)t.i;
break;
case MODULE_OPT_TYPE_UINT:
- (void)strtoul (data, &err_str, 10);
+ t.ui = strtoul (data, &err_str, 10);
if (*err_str != '\0') {
msg_warn ("non-numeric data for option: '%s' for module: '%s' at position: '%s'", optname, mname, err_str);
return FALSE;
}
+ (void)t.ui;
break;
case MODULE_OPT_TYPE_DOUBLE:
- (void)strtod (data, &err_str);
+ t.d = strtod (data, &err_str);
if (*err_str != '\0') {
msg_warn ("non-numeric data for option: '%s' for module: '%s' at position: '%s'", optname, mname, err_str);
return FALSE;
}
+ (void)t.d;
break;
case MODULE_OPT_TYPE_TIME:
- (void)cfg_parse_time (data, TIME_SECONDS);
+ t.ui = cfg_parse_time (data, TIME_SECONDS);
if (errno != 0) {
msg_warn ("non-numeric data for option: '%s' for module: '%s': %s", optname, mname, strerror (errno));
return FALSE;
}
+ (void)t.ui;
break;
case MODULE_OPT_TYPE_SIZE:
- (void)parse_limit (data, -1);
+ t.ui = parse_limit (data, -1);
if (errno != 0) {
msg_warn ("non-numeric data for option: '%s' for module: '%s': %s", optname, mname, strerror (errno));
return FALSE;
}
+ (void)t.ui;
break;
case MODULE_OPT_TYPE_MAP:
if (!check_map_proto (data, NULL, NULL)) {
diff --git a/src/diff.c b/src/diff.c
index 56f4498ca..f7606cb04 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -225,7 +225,12 @@ static gint
_ses(const void *a, gint aoff, gint n, const void *b, gint boff,
gint m, struct _ctx *ctx)
{
- struct middle_snake ms;
+ struct middle_snake ms = {
+ .x = 0,
+ .y = 0,
+ .u = 0,
+ .v = 0
+ };
gint d;
if (n == 0) {
diff --git a/src/expressions.c b/src/expressions.c
index 3012d2d5d..99277dfd2 100644
--- a/src/expressions.c
+++ b/src/expressions.c
@@ -1144,7 +1144,7 @@ rspamd_content_type_compare_param (struct worker_task * task, GList * args, void
GMimeContentType *ct;
gint r;
gboolean recursive = FALSE, result = FALSE;
- GList *cur;
+ GList *cur = NULL;
struct mime_part *cur_part;
if (args == NULL) {
@@ -1253,7 +1253,7 @@ rspamd_content_type_has_param (struct worker_task * task, GList * args, void *un
GMimeObject *part;
GMimeContentType *ct;
gboolean recursive = FALSE, result = FALSE;
- GList *cur;
+ GList *cur = NULL;
struct mime_part *cur_part;
if (args == NULL) {
@@ -1326,7 +1326,7 @@ rspamd_content_type_is_subtype (struct worker_task *task, GList * args, void *un
GMimeContentType *ct;
gint r;
gboolean recursive = FALSE, result = FALSE;
- GList *cur;
+ GList *cur = NULL;
struct mime_part *cur_part;
if (args == NULL) {
@@ -1423,7 +1423,7 @@ rspamd_content_type_is_type (struct worker_task * task, GList * args, void *unus
GMimeContentType *ct;
gint r;
gboolean recursive = FALSE, result = FALSE;
- GList *cur;
+ GList *cur = NULL;
struct mime_part *cur_part;
if (args == NULL) {
diff --git a/src/kvstorage_config.c b/src/kvstorage_config.c
index 0902c7303..fd259c834 100644
--- a/src/kvstorage_config.c
+++ b/src/kvstorage_config.c
@@ -87,8 +87,8 @@ kvstorage_init_callback (const gpointer key, const gpointer value, gpointer unus
{
struct kvstorage_config *kconf = value;
struct rspamd_kv_cache *cache;
- struct rspamd_kv_backend *backend;
- struct rspamd_kv_expire *expire;
+ struct rspamd_kv_backend *backend = NULL;
+ struct rspamd_kv_expire *expire = NULL;
switch (kconf->cache.type) {
case KVSTORAGE_TYPE_CACHE_HASH:
diff --git a/src/kvstorage_file.c b/src/kvstorage_file.c
index 73e5a8a88..de06f778b 100644
--- a/src/kvstorage_file.c
+++ b/src/kvstorage_file.c
@@ -339,11 +339,17 @@ rspamd_recursive_mkdir (guint levels)
return FALSE;
}
else if (levels > 1) {
- chdir (nbuf);
+ if (chdir (nbuf) == -1) {
+ msg_err ("chdir to %s failed: %s", nbuf, strerror (errno));
+ return FALSE;
+ }
if (! rspamd_recursive_mkdir (levels - 1)) {
return FALSE;
}
- chdir ("../");
+ if (chdir ("../") == -1) {
+ msg_err ("chdir to ../ failed: %s", strerror (errno));
+ return FALSE;
+ }
}
}
}
@@ -378,11 +384,15 @@ rspamd_file_init (struct rspamd_kv_backend *backend)
db->initialized = TRUE;
- chdir (pathbuf);
+ if (chdir (pathbuf) == -1) {
+ msg_err ("chdir to %s failed: %s", pathbuf, strerror (errno));
+ }
return;
err:
if (pathbuf[0] != '\0') {
- chdir (pathbuf);
+ if (chdir (pathbuf) == -1) {
+ msg_err ("chdir to %s failed: %s", pathbuf, strerror (errno));
+ }
}
}
diff --git a/src/kvstorage_server.c b/src/kvstorage_server.c
index 7cf53f1a0..c55c7c37e 100644
--- a/src/kvstorage_server.c
+++ b/src/kvstorage_server.c
@@ -222,7 +222,7 @@ static gboolean
parse_kvstorage_line (struct kvstorage_session *session, f_str_t *in)
{
gchar *p, *c, *end;
- gint state = 0, next_state;
+ gint state = 0, next_state = 0;
gboolean is_redis;
p = in->begin;
@@ -648,6 +648,7 @@ kvstorage_read_arglen (f_str_t *in, guint *len)
gchar *p = in->begin, *end = in->begin + in->len, *c;
gint state = 0;
+ c = p;
while (p < end) {
switch (state) {
case 0:
@@ -716,7 +717,7 @@ kvstorage_read_socket (f_str_t * in, void *arg)
struct kvstorage_session *session = (struct kvstorage_session *) arg;
struct kvstorage_worker_thread *thr;
gint r;
- guint arglen;
+ guint arglen = 0;
gchar outbuf[BUFSIZ];
gboolean is_redis;
diff --git a/src/message.c b/src/message.c
index 19d56f7df..bf955ae94 100644
--- a/src/message.c
+++ b/src/message.c
@@ -470,9 +470,9 @@ parse_recv_header (memory_pool_t * pool, gchar *line, struct received_header *r)
static void
process_raw_headers (struct worker_task *task)
{
- struct raw_header *new, *lp;
+ struct raw_header *new = NULL, *lp;
gchar *p, *c, *tmp, *tp;
- gint state = 0, l, next_state, err_state, t_state;
+ gint state = 0, l, next_state = 100, err_state = 100, t_state;
gboolean valid_folding = FALSE;
p = task->raw_headers_str;
diff --git a/src/protocol.c b/src/protocol.c
index 70ba1bd83..51290cdf1 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -292,10 +292,11 @@ static gboolean
parse_http_command (struct worker_task *task, f_str_t * line)
{
guint8 *p, *end, *c;
- gint state = 0, next_state;
+ gint state = 0, next_state = 0;
gchar *cmd;
p = line->begin;
+ c = p;
end = p + line->len;
task->proto = RSPAMC_PROTO;
diff --git a/src/url.c b/src/url.c
index 8e0449093..ade68ea1c 100644
--- a/src/url.c
+++ b/src/url.c
@@ -918,9 +918,10 @@ url_file_end (const gchar *begin, const gchar *end, const gchar *pos, url_match_
{
const gchar *p;
gchar stop;
- guint i;
+ guint i;
p = pos + strlen (match->pattern);
+ stop = *p;
if (*p == '/') {
p ++;
}
diff --git a/src/util.c b/src/util.c
index c5ec0145e..23203255b 100644
--- a/src/util.c
+++ b/src/util.c
@@ -408,7 +408,9 @@ write_pid (struct rspamd_main *main)
if (main->is_privilleged) {
/* Force root user as owner of pid file */
- fchown (main->pfh->pf_fd, 0, 0);
+ if (fchown (main->pfh->pf_fd, 0, 0) == -1) {
+ msg_err ("cannot chown of pidfile %s to 0:0 user", main->cfg->pid_file);
+ }
}
rspamd_pidfile_write (main->pfh);