aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-15 19:24:51 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-15 19:24:51 +0000
commite0446369d13269d07cecb5711fbab7d7bc64398a (patch)
treebcd2380195721fef0e51740653c73d4b71e9ce9b
parent6ffffe0d5f155aa5d212df92d97c62e2de71baa3 (diff)
downloadrspamd-e0446369d13269d07cecb5711fbab7d7bc64398a.tar.gz
rspamd-e0446369d13269d07cecb5711fbab7d7bc64398a.zip
[Minor] Fix some outbound access issues
Found by: Coverity
-rw-r--r--src/libmime/mime_expressions.c3
-rw-r--r--src/libstat/stat_config.c3
-rw-r--r--src/libutil/util.c4
-rw-r--r--src/plugins/spf.c6
4 files changed, 8 insertions, 8 deletions
diff --git a/src/libmime/mime_expressions.c b/src/libmime/mime_expressions.c
index d848f797d..637cccad3 100644
--- a/src/libmime/mime_expressions.c
+++ b/src/libmime/mime_expressions.c
@@ -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;
diff --git a/src/libstat/stat_config.c b/src/libstat/stat_config.c
index b6b9000d5..ab64e81a4 100644
--- a/src/libstat/stat_config.c
+++ b/src/libstat/stat_config.c
@@ -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",
diff --git a/src/libutil/util.c b/src/libutil/util.c
index 832b7dfb7..704d65041 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -563,10 +563,6 @@ rspamd_sockets_list (const gchar *credits, guint16 port,
freeaddrinfo (res);
if (result == NULL) {
- if (fd != -1) {
- close (fd);
- }
-
goto err;
}
}
diff --git a/src/plugins/spf.c b/src/plugins/spf.c
index d7b76e003..e51016429 100644
--- a/src/plugins/spf.c
+++ b/src/plugins/spf.c
@@ -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;
}