while (g_ascii_isspace (*line)) {
line++;
}
- if (line == '\0') {
+ if (*line == '\0') {
msg_warn ("got empty regexp");
return NULL;
}
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 ++) {
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));
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
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>");
part->script = sel;
}
+ if (total == 0) {
+ return 0;
+ }
+
return ((double)mark / (double)total) > chartable_module_ctx->threshold;
}
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;
}
}
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");
GError *err = NULL;
struct url_regexp_param callback_param = {
.task = task,
- .regexp = re->regexp,
.re = re,
.found = FALSE
};
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;
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) {
}
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);
/**
* 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)