]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix couple of warnings
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 27 Oct 2017 09:55:20 +0000 (10:55 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 27 Oct 2017 09:55:20 +0000 (10:55 +0100)
contrib/hiredis/dict.c
contrib/hiredis/hiredis.c
contrib/libucl/ucl_parser.c
src/libmime/archives.c
src/libserver/dkim.c
src/libserver/spf.c
src/libutil/ssl_util.c
src/plugins/fuzzy_check.c

index e17a625461a7c6988d56fb1b3119c643464431a9..0fbc1b4cfb9acee28ae642bfb8934829e64ed2f3 100644 (file)
@@ -172,9 +172,11 @@ static int dictReplace(dict *ht, void *key, void *val) {
      * as the previous one. In this context, think to reference counting,
      * you want to increment (set), and then decrement (free), and not the
      * reverse. */
-    auxentry = *entry;
-    dictSetHashVal(ht, entry, val);
-    dictFreeEntryVal(ht, &auxentry);
+    if (entry) {
+        auxentry = *entry;
+        dictSetHashVal(ht, entry, val);
+        dictFreeEntryVal(ht, &auxentry);
+    }
     return 0;
 }
 
index 2b876d91310856d3035dd37e5f9ce02522d7dc0d..0f87bc3238f74aad70a1661bdeeff8b727bc60d5 100644 (file)
@@ -710,6 +710,8 @@ redisContext *redisConnectNonBlock(const char *ip, int port) {
 redisContext *redisConnectBindNonBlock(const char *ip, int port,
                                        const char *source_addr) {
     redisContext *c = redisContextInit();
+    if (c == NULL)
+        return NULL;
     c->flags &= ~REDIS_BLOCK;
     redisContextConnectBindTcp(c,ip,port,NULL,source_addr);
     return c;
@@ -718,6 +720,8 @@ redisContext *redisConnectBindNonBlock(const char *ip, int port,
 redisContext *redisConnectBindNonBlockWithReuse(const char *ip, int port,
                                                 const char *source_addr) {
     redisContext *c = redisContextInit();
+    if (c == NULL)
+        return NULL;
     c->flags &= ~REDIS_BLOCK;
     c->flags |= REDIS_REUSEADDR;
     redisContextConnectBindTcp(c,ip,port,NULL,source_addr);
index d6b8eb656d6a9d2c73b7aab489165c574cb9d311..11b871259593689924409f91c83130e8cc2938f7 100644 (file)
@@ -1608,8 +1608,17 @@ ucl_parse_value (struct ucl_parser *parser, struct ucl_chunk *chunk)
                        break;
                case '{':
                        obj = ucl_parser_get_container (parser);
+                       if (obj == NULL) {
+                               return false;
+                       }
                        /* We have a new object */
-                       obj = ucl_parser_add_container (obj, parser, false, parser->stack->level);
+                       if (parser->stack) {
+                               obj = ucl_parser_add_container (obj, parser, false,
+                                               parser->stack->level);
+                       }
+                       else {
+                               return false;
+                       }
                        if (obj == NULL) {
                                return false;
                        }
@@ -1620,8 +1629,18 @@ ucl_parse_value (struct ucl_parser *parser, struct ucl_chunk *chunk)
                        break;
                case '[':
                        obj = ucl_parser_get_container (parser);
+                       if (obj == NULL) {
+                               return false;
+                       }
                        /* We have a new array */
-                       obj = ucl_parser_add_container (obj, parser, true, parser->stack->level);
+                       if (parser->stack) {
+                               obj = ucl_parser_add_container (obj, parser, true,
+                                               parser->stack->level);
+                       }
+                       else {
+                               return false;
+                       }
+
                        if (obj == NULL) {
                                return false;
                        }
index 118da921c3deb05a8a3da1e6c339f7a0c3c94ecf..28e898beef49eefdcb13605e22573354a561d298 100644 (file)
@@ -700,7 +700,7 @@ rspamd_7zip_read_bits (struct rspamd_task *task,
                struct rspamd_archive *arch, guint nbits,
                guint *pbits_set)
 {
-       unsigned mask, avail, i;
+       unsigned mask = 0, avail = 0, i;
        gboolean bit_set = 0;
 
        for (i = 0; i < nbits; i++) {
@@ -710,7 +710,7 @@ rspamd_7zip_read_bits (struct rspamd_task *task,
                        mask = 0x80;
                }
 
-               bit_set = (avail & mask)?1:0;
+               bit_set = (avail & mask) ? 1 : 0;
 
                if (bit_set && pbits_set) {
                        (*pbits_set) ++;
index 0eaa9937ed0cd29847cdff0f425b19b058dc0d17..12bc146ab8969ea9c7189fcf8564d6ff9509e6f9 100644 (file)
@@ -2820,6 +2820,7 @@ rspamd_dkim_sign (struct rspamd_task *task, const gchar *selector,
 
        switch (ctx->common.type) {
        case RSPAMD_DKIM_NORMAL:
+       default:
                hname = RSPAMD_DKIM_SIGNHEADER;
                break;
        case RSPAMD_DKIM_ARC_SIG:
index a29e77c07fd8e894735f3fa4931a5e44d867c148..edce244b985485c64f3e1e0ec592643216f67f53 100644 (file)
@@ -1474,9 +1474,9 @@ static const gchar *
 expand_spf_macro (struct spf_record *rec, struct spf_resolved_element *resolved,
                const gchar *begin)
 {
-       const gchar *p, *macro_value;
-       gchar *c, *new, *tmp, delim;
-       gsize len = 0, slen = 0, macro_len;
+       const gchar *p, *macro_value = NULL;
+       gchar *c, *new, *tmp, delim = '.';
+       gsize len = 0, slen = 0, macro_len = 0;
        gint state = 0, ndelim = 0;
        gchar ip_buf[INET6_ADDRSTRLEN + 1];
        gboolean need_expand = FALSE, reversed;
index 5b181f1bc4e6ea24a7b0dec1dde1943b3de13cfc..6d76beabd94e3b4fd5387223451a615d720bf3a1 100644 (file)
@@ -364,7 +364,7 @@ rspamd_tls_set_error (gint retcode, const gchar *stage, GError **err)
 {
        GString *reason;
        gchar buf[120];
-       gint err_code, last_err;
+       gint err_code = 0, last_err = 0;
 
        reason = g_string_sized_new (sizeof (buf));
 
index acf36a975a97fbb7775136b51f3a4dd9a7213840..a7a198dad32e15ef2e1d6e6203e0bdf7ac80cd86 100644 (file)
@@ -2830,7 +2830,7 @@ fuzzy_process_handler (struct rspamd_http_connection_entry *conn_ent,
        struct fuzzy_rule *rule;
        struct rspamd_controller_session *session = conn_ent->ud;
        struct rspamd_task *task, **ptask;
-       gboolean processed = FALSE, res = TRUE, skip;
+       gboolean processed = FALSE, res = TRUE, skip = FALSE;
        guint i;
        GError **err;
        GPtrArray *commands;
@@ -2935,7 +2935,7 @@ fuzzy_process_handler (struct rspamd_http_connection_entry *conn_ent,
                if (is_hash) {
                        GPtrArray *args;
                        const rspamd_ftok_t *arg;
-                       guint i;
+                       guint j;
 
                        args = rspamd_http_message_find_header_multiple (msg, "Hash");
 
@@ -2943,8 +2943,8 @@ fuzzy_process_handler (struct rspamd_http_connection_entry *conn_ent,
                                struct fuzzy_cmd_io *io;
                                commands = g_ptr_array_sized_new (args->len);
 
-                               for (i = 0; i < args->len; i ++) {
-                                       arg = g_ptr_array_index (args, i);
+                               for (j = 0; j < args->len; j ++) {
+                                       arg = g_ptr_array_index (args, j);
                                        io = fuzzy_cmd_hash (rule, cmd, arg, flag, value,
                                                        task->task_pool);
 
@@ -2996,6 +2996,7 @@ fuzzy_process_handler (struct rspamd_http_connection_entry *conn_ent,
                                strerror (errno));
                rspamd_controller_send_error (conn_ent, 400, "Message sending error");
                rspamd_task_free (task);
+
                return;
        }
        else if (!processed) {
@@ -3019,11 +3020,7 @@ fuzzy_process_handler (struct rspamd_http_connection_entry *conn_ent,
                        }
                }
                rspamd_task_free (task);
-
-               return;
        }
-
-       return;
 }
 
 static int