]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix some outbound access issues
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 15 Jan 2017 19:24:51 +0000 (19:24 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 15 Jan 2017 19:24:51 +0000 (19:24 +0000)
Found by: Coverity

src/libmime/mime_expressions.c
src/libstat/stat_config.c
src/libutil/util.c
src/plugins/spf.c

index d848f797dea263530ae1249b7cf11379c4bb8811..637cccad3ecd89ec135f67c8b33947613eb93e26 100644 (file)
@@ -1229,6 +1229,9 @@ is_recipient_list_sorted (GPtrArray *ar)
                return FALSE;
        }
 
+       prev.len = 0;
+       prev.begin = NULL;
+
        PTR_ARRAY_FOREACH (ar, i, addr) {
                cur.begin = addr->addr;
                cur.len = addr->addr_len;
index b6b9000d57b11700b1b3725a15351771bb69c4f9..ab64e81a44a79906abf548e6aa2bf5131ab699ff 100644 (file)
@@ -166,6 +166,7 @@ rspamd_stat_init (struct rspamd_config *cfg, struct event_base *ev_base)
        cur = cfg->classifiers;
 
        while (cur) {
+               bk = NULL;
                clf = cur->data;
                cl = g_slice_alloc0 (sizeof (*cl));
                cl->cfg = clf;
@@ -239,7 +240,7 @@ rspamd_stat_init (struct rspamd_config *cfg, struct event_base *ev_base)
                        st->classifier = cl;
                        st->stcf = stf;
 
-                       if (!(cl->cfg->flags & RSPAMD_FLAG_CLASSIFIER_NO_BACKEND)) {
+                       if (!(cl->cfg->flags & RSPAMD_FLAG_CLASSIFIER_NO_BACKEND) && bk) {
                                st->backend = bk;
                                st->bkcf = bk->init (stat_ctx, cfg, st);
                                msg_debug_config ("added backend %s for symbol %s",
index 832b7dfb7fc7c5b73b75ef9941e17535774bde18..704d65041836e387149894ee0cac26ecdade1eac 100644 (file)
@@ -563,10 +563,6 @@ rspamd_sockets_list (const gchar *credits, guint16 port,
                                freeaddrinfo (res);
 
                                if (result == NULL) {
-                                       if (fd != -1) {
-                                               close (fd);
-                                       }
-
                                        goto err;
                                }
                        }
index d7b76e003e4813ab22fb8a2151d8e4887e85a774..e51016429b7a0ca7079c653be08f175d61fa2017 100644 (file)
@@ -374,16 +374,16 @@ spf_check_element (struct spf_resolved *rec, struct spf_addr *addr,
 
                /* Compare the first bytes */
                bmask = mask / CHAR_BIT;
-               if (bmask > addrlen) {
+               if (mask > addrlen * CHAR_BIT) {
                        msg_info_task ("bad mask length: %d", mask);
                }
                else if (memcmp (s, d, bmask) == 0) {
-
-                       if (bmask * CHAR_BIT != mask) {
+                       if (bmask * CHAR_BIT < mask) {
                                /* Compare the remaining bits */
                                s += bmask;
                                d += bmask;
                                mask = (0xff << (CHAR_BIT - (mask - bmask * 8))) & 0xff;
+
                                if ((*s & mask) == (*d & mask)) {
                                        res = TRUE;
                                }