@@ -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; | |||
} |
@@ -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 ++) { |
@@ -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)); |
@@ -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 |
@@ -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>"); |
@@ -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; | |||
} | |||
@@ -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"); |
@@ -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) { |
@@ -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 (¶m->redirector->up, param->task->tv.tv_sec); |
@@ -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) |