aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/expressions.c2
-rw-r--r--src/fstring.c4
-rw-r--r--src/fuzzy_storage.c1
-rw-r--r--src/lua/lua_task.c2
-rw-r--r--src/lua/lua_xmlrpc.c2
-rw-r--r--src/plugins/chartable.c4
-rw-r--r--src/plugins/fuzzy_check.c4
-rw-r--r--src/plugins/regexp.c6
-rw-r--r--src/plugins/surbl.c6
-rw-r--r--src/printf.c2
10 files changed, 23 insertions, 10 deletions
diff --git a/src/expressions.c b/src/expressions.c
index 6a88514c9..c8247e40d 100644
--- a/src/expressions.c
+++ b/src/expressions.c
@@ -605,7 +605,7 @@ parse_regexp (memory_pool_t * pool, gchar *line, gboolean raw_mode)
while (g_ascii_isspace (*line)) {
line++;
}
- if (line == '\0') {
+ if (*line == '\0') {
msg_warn ("got empty regexp");
return NULL;
}
diff --git a/src/fstring.c b/src/fstring.c
index 9f17ac861..8028d15a3 100644
--- a/src/fstring.c
+++ b/src/fstring.c
@@ -398,7 +398,9 @@ fstrhash_lowercase (f_str_t * str, gboolean is_utf)
if (is_utf) {
while (end < str->begin + str->len) {
- g_utf8_validate (p, str->len, &end);
+ if (!g_utf8_validate (p, str->len, &end)) {
+ return fstrhash_lowercase (str, FALSE);
+ }
while (p < end) {
uc = g_unichar_tolower (g_utf8_get_char (p));
for (j = 0; j < sizeof (gunichar); j ++) {
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index 7bd950014..14df0e54d 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -471,6 +471,7 @@ read_hashes_file (struct rspamd_worker *wrk)
version = (gint)header[3];
if (version > CURRENT_FUZZY_VERSION) {
msg_err ("unsupported version of fuzzy hash file: %d", version);
+ close (fd);
return FALSE;
}
msg_info ("reading fuzzy hashes storage file of version %d of size %d", version, (gint)(st.st_size - sizeof (header)) / sizeof (struct rspamd_fuzzy_node));
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 014a994e0..d78aff036 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -1763,7 +1763,7 @@ lua_textpart_compare_distance (lua_State * L)
luaL_argcheck (L, ud != NULL, 2, "'textpart' expected");
other = ud ? *((struct mime_text_part **)ud) : NULL;
- if (part->parent && part->parent == other->parent) {
+ if (other != NULL && part->parent && part->parent == other->parent) {
parent = part->parent;
ct = g_mime_object_get_content_type (parent);
#ifndef GMIME24
diff --git a/src/lua/lua_xmlrpc.c b/src/lua/lua_xmlrpc.c
index 57691cda5..4608d2328 100644
--- a/src/lua/lua_xmlrpc.c
+++ b/src/lua/lua_xmlrpc.c
@@ -472,7 +472,7 @@ lua_xmlrpc_parse_table (lua_State *L, gint pos, gchar *databuf, gint pr, gsize s
break;
case LUA_TTABLE:
/* Recursive call */
- r += lua_xmlrpc_parse_table (L, -1, databuf, r, sizeof (databuf));
+ r += lua_xmlrpc_parse_table (L, -1, databuf + r, r, size);
break;
}
r += rspamd_snprintf (databuf + r, size - r, "</value></member>");
diff --git a/src/plugins/chartable.c b/src/plugins/chartable.c
index 3f680647a..c1b8826e6 100644
--- a/src/plugins/chartable.c
+++ b/src/plugins/chartable.c
@@ -194,6 +194,10 @@ check_part (struct mime_text_part *part, gboolean raw_mode)
part->script = sel;
}
+ if (total == 0) {
+ return 0;
+ }
+
return ((double)mark / (double)total) > chartable_module_ctx->threshold;
}
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index 33e710c90..50c491730 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -584,7 +584,7 @@ ok:
r = rspamd_snprintf (buf, sizeof (buf), "write error: %s" CRLF "END" CRLF, (*session->err)->message);
}
g_error_free (*session->err);
- if (! rspamd_dispatcher_write (session->session->dispatcher, buf, r, FALSE, FALSE)) {
+ if (r > 0 && ! rspamd_dispatcher_write (session->session->dispatcher, buf, r, FALSE, FALSE)) {
return;
}
}
@@ -834,7 +834,7 @@ fuzzy_process_handler (struct controller_session *session, f_str_t * in)
saved = memory_pool_alloc0 (session->session_pool, sizeof (gint));
- err = memory_pool_alloc0 (session->session_pool, sizeof (GError **));
+ err = memory_pool_alloc0 (session->session_pool, sizeof (GError *));
r = process_message (task);
if (r == -1) {
msg_warn ("processing of message failed");
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index b838b1ee6..219b5b815 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -729,7 +729,6 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const gchar
GError *err = NULL;
struct url_regexp_param callback_param = {
.task = task,
- .regexp = re->regexp,
.re = re,
.found = FALSE
};
@@ -741,6 +740,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const gchar
return 0;
}
+ callback_param.regexp = re->regexp;
if ((r = task_cache_check (task, re)) != -1) {
debug_task ("regexp /%s/ is found in cache, result: %d", re->regexp_text, r);
return r == 1;
@@ -2056,6 +2056,10 @@ compare_subtype (struct worker_task *task, GMimeContentType * ct, gchar *subtype
struct rspamd_regexp *re;
gint r;
+ if (subtype == NULL || ct == NULL) {
+ msg_warn ("invalid parameters passed");
+ return FALSE;
+ }
if (*subtype == '/') {
/* This is regexp, so compile and create g_regexp object */
if ((re = re_cache_check (subtype, task->cfg->cfg_pool)) == NULL) {
diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c
index 7125e5aa7..7703a73aa 100644
--- a/src/plugins/surbl.c
+++ b/src/plugins/surbl.c
@@ -891,8 +891,10 @@ redirector_callback (gint fd, short what, void *arg)
}
if (found) {
debug_task ("<%s> got reply from redirector: '%s' -> '%s'", param->task->message_id, struri (param->url), c);
- parse_uri (param->url, memory_pool_strdup (param->task->task_pool, c), param->task->task_pool);
- make_surbl_requests (param->url, param->task, param->suffix, FALSE);
+ r = parse_uri (param->url, memory_pool_strdup (param->task->task_pool, c), param->task->task_pool);
+ if (r == URI_ERRNO_OK || r == URI_ERRNO_NO_SLASHES || r == URI_ERRNO_NO_HOST_SLASH) {
+ make_surbl_requests (param->url, param->task, param->suffix, FALSE);
+ }
}
}
upstream_ok (&param->redirector->up, param->task->tv.tv_sec);
diff --git a/src/printf.c b/src/printf.c
index 02b4ee09d..00730d16c 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -28,7 +28,7 @@
/**
* From FreeBSD libutil code
*/
-static const int maxscale = 7;
+static const int maxscale = 6;
static gchar *
rspamd_humanize_number (gchar *buf, gchar *last, gint64 num, gboolean bytes)