@@ -43,7 +43,6 @@ INCLUDE(FindPerl) | |||
# Initial set | |||
SET(CMAKE_REQUIRED_LIBRARIES m) | |||
SET(CMAKE_REQUIRED_INCLUDES sys/mman.h stdlib.h stdio.h unistd.h time.h sched.h) | |||
IF(CMAKE_INSTALL_PREFIX) | |||
SET(PREFIX ${CMAKE_INSTALL_PREFIX}) | |||
@@ -127,7 +126,13 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") | |||
IF(NOT MAN_PREFIX) | |||
SET(MAN_PREFIX /usr/share/man) | |||
ENDIF(NOT MAN_PREFIX) | |||
ENDIF(CMAKE_INSTALL_PREFIX) | |||
ENDIF(CMAKE_INSTALL_PREFIX) | |||
# Workaround with architecture specific includes | |||
IF(IS_DIRECTORY "/usr/include/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/") | |||
INCLUDE_DIRECTORIES("/usr/include/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/") | |||
SET(CMAKE_REQUIRED_INCLUDES "/usr/include/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/") | |||
ENDIF(IS_DIRECTORY "/usr/include/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/") | |||
LIST(APPEND CMAKE_REQUIRED_LIBRARIES rt) | |||
LIST(APPEND CMAKE_REQUIRED_LIBRARIES dl) |
@@ -1611,7 +1611,7 @@ rspamd_xml_start_element (GMarkupParseContext *context, const gchar *element_nam | |||
*error = g_error_new (xml_error_quark (), XML_PARAM_MISSING, "param 'condition' is required for tag 'if'"); | |||
ud->state = XML_ERROR; | |||
} | |||
if (! lua_check_condition (ud->cfg, condition)) { | |||
else if (! lua_check_condition (ud->cfg, condition)) { | |||
ud->state = XML_SKIP_ELEMENTS; | |||
} | |||
return; |
@@ -342,7 +342,7 @@ rspamd_diff(const void *a, gint aoff, gint n, const void *b, gint boff, gint m, | |||
g_array_free (tmp, TRUE); | |||
return -1; | |||
} | |||
if (ses && sn) { | |||
if (ses && sn && e) { | |||
*sn = e->op ? ctx.si + 1 : 0; | |||
} | |||
@@ -666,7 +666,7 @@ parse_regexp (memory_pool_t * pool, gchar *line, gboolean raw_mode) | |||
else { | |||
result->header = memory_pool_strdup (pool, line); | |||
result->type = REGEXP_HEADER; | |||
line = begin; | |||
line = start; | |||
} | |||
/* Find begin of regexp */ | |||
while (*line && *line != '/') { |
@@ -456,7 +456,7 @@ file_log_function (const gchar * log_domain, const gchar *function, GLogLevelFla | |||
time_t now; | |||
struct tm *tms; | |||
struct iovec iov[4]; | |||
gint r; | |||
gint r = 0; | |||
guint32 cksum; | |||
size_t mlen; | |||
const gchar *cptype = NULL; |
@@ -49,7 +49,7 @@ lua_check_cdb (lua_State * L) | |||
void *ud = luaL_checkudata (L, 1, "rspamd{cdb}"); | |||
luaL_argcheck (L, ud != NULL, 1, "'cdb' expected"); | |||
return *((struct cdb **)ud); | |||
return ud ? *((struct cdb **)ud) : NULL; | |||
} | |||
static gint |
@@ -72,7 +72,7 @@ lua_check_classifier (lua_State * L) | |||
{ | |||
void *ud = luaL_checkudata (L, 1, "rspamd{classifier}"); | |||
luaL_argcheck (L, ud != NULL, 1, "'classifier' expected"); | |||
return *((struct classifier_config **)ud); | |||
return ud ? *((struct classifier_config **)ud) : NULL; | |||
} | |||
static GList * | |||
@@ -353,7 +353,7 @@ lua_check_statfile (lua_State * L) | |||
{ | |||
void *ud = luaL_checkudata (L, 1, "rspamd{statfile}"); | |||
luaL_argcheck (L, ud != NULL, 1, "'statfile' expected"); | |||
return *((struct statfile **)ud); | |||
return ud ? *((struct statfile **)ud) : NULL; | |||
} | |||
@@ -109,7 +109,7 @@ lua_check_config (lua_State * L) | |||
{ | |||
void *ud = luaL_checkudata (L, 1, "rspamd{config}"); | |||
luaL_argcheck (L, ud != NULL, 1, "'config' expected"); | |||
return *((struct config_file **)ud); | |||
return ud ? *((struct config_file **)ud) : NULL; | |||
} | |||
static radix_tree_t * | |||
@@ -117,7 +117,7 @@ lua_check_radix (lua_State * L) | |||
{ | |||
void *ud = luaL_checkudata (L, 1, "rspamd{radix}"); | |||
luaL_argcheck (L, ud != NULL, 1, "'radix' expected"); | |||
return **((radix_tree_t ***)ud); | |||
return ud ? **((radix_tree_t ***)ud) : NULL; | |||
} | |||
static GHashTable * | |||
@@ -125,7 +125,7 @@ lua_check_hash_table (lua_State * L) | |||
{ | |||
void *ud = luaL_checkudata (L, 1, "rspamd{hash_table}"); | |||
luaL_argcheck (L, ud != NULL, 1, "'hash_table' expected"); | |||
return **((GHashTable ***)ud); | |||
return ud ? **((GHashTable ***)ud) : NULL; | |||
} | |||
static rspamd_trie_t * | |||
@@ -134,7 +134,7 @@ lua_check_trie (lua_State * L) | |||
void *ud = luaL_checkudata (L, 1, "rspamd{trie}"); | |||
luaL_argcheck (L, ud != NULL, 1, "'trie' expected"); | |||
return *((rspamd_trie_t **)ud); | |||
return ud ? *((rspamd_trie_t **)ud) : NULL; | |||
} | |||
/*** Config functions ***/ | |||
@@ -764,7 +764,7 @@ lua_trie_search_task (lua_State *L) | |||
if (trie) { | |||
ud = luaL_checkudata (L, 2, "rspamd{task}"); | |||
luaL_argcheck (L, ud != NULL, 1, "'task' expected"); | |||
task = *((struct worker_task **)ud); | |||
task = ud ? *((struct worker_task **)ud) : NULL; | |||
if (task) { | |||
lua_newtable (L); | |||
cur = task->text_parts; |
@@ -63,7 +63,7 @@ lua_check_task (lua_State * L) | |||
{ | |||
void *ud = luaL_checkudata (L, 1, "rspamd{task}"); | |||
luaL_argcheck (L, ud != NULL, 1, "'task' expected"); | |||
return *((struct worker_task **)ud); | |||
return ud ? *((struct worker_task **)ud) : NULL; | |||
} | |||
static void |
@@ -94,7 +94,7 @@ lua_check_message (lua_State * L) | |||
{ | |||
void *ud = luaL_checkudata (L, 1, "rspamd{message}"); | |||
luaL_argcheck (L, ud != NULL, 1, "'message' expected"); | |||
return *((GMimeMessage **) ud); | |||
return ud ? *((GMimeMessage **) ud) : NULL; | |||
} | |||
@@ -53,7 +53,7 @@ lua_check_regexp (lua_State * L) | |||
void *ud = luaL_checkudata (L, 1, "rspamd{regexp}"); | |||
luaL_argcheck (L, ud != NULL, 1, "'regexp' expected"); | |||
return *((GRegex **)ud); | |||
return ud ? *((GRegex **)ud) : NULL; | |||
} | |||
static int |
@@ -166,7 +166,7 @@ lua_check_task (lua_State * L) | |||
{ | |||
void *ud = luaL_checkudata (L, 1, "rspamd{task}"); | |||
luaL_argcheck (L, ud != NULL, 1, "'task' expected"); | |||
return *((struct worker_task **)ud); | |||
return ud ? *((struct worker_task **)ud) : NULL; | |||
} | |||
static struct mime_text_part * | |||
@@ -174,7 +174,7 @@ lua_check_textpart (lua_State * L) | |||
{ | |||
void *ud = luaL_checkudata (L, 1, "rspamd{textpart}"); | |||
luaL_argcheck (L, ud != NULL, 1, "'textpart' expected"); | |||
return *((struct mime_text_part **)ud); | |||
return ud ? *((struct mime_text_part **)ud) : NULL; | |||
} | |||
static struct rspamd_image * | |||
@@ -182,7 +182,7 @@ lua_check_image (lua_State * L) | |||
{ | |||
void *ud = luaL_checkudata (L, 1, "rspamd{image}"); | |||
luaL_argcheck (L, ud != NULL, 1, "'image' expected"); | |||
return *((struct rspamd_image **)ud); | |||
return ud ? *((struct rspamd_image **)ud) : NULL; | |||
} | |||
static struct uri * | |||
@@ -190,7 +190,7 @@ lua_check_url (lua_State * L) | |||
{ | |||
void *ud = luaL_checkudata (L, 1, "rspamd{url}"); | |||
luaL_argcheck (L, ud != NULL, 1, "'url' expected"); | |||
return *((struct uri **)ud); | |||
return ud ? *((struct uri **)ud) : NULL; | |||
} | |||
/*** Task interface ***/ | |||
@@ -1355,7 +1355,7 @@ lua_textpart_compare_distance (lua_State * L) | |||
const GMimeContentType *ct; | |||
luaL_argcheck (L, ud != NULL, 2, "'textpart' expected"); | |||
other = *((struct mime_text_part **)ud); | |||
other = ud ? *((struct mime_text_part **)ud) : NULL; | |||
if (part->parent && part->parent == other->parent) { | |||
parent = part->parent; |
@@ -513,7 +513,7 @@ memory_pool_delete (memory_pool_t * pool) | |||
cur_shared = cur_shared->next; | |||
STAT_LOCK (); | |||
mem_pool_stat->chunks_freed++; | |||
mem_pool_stat->bytes_allocated -= tmp->len; | |||
mem_pool_stat->bytes_allocated -= tmp_shared->len; | |||
STAT_UNLOCK (); | |||
munmap ((void *)tmp_shared, tmp_shared->len + sizeof (struct _pool_chain_shared)); | |||
} |
@@ -271,7 +271,7 @@ parse_servers_string (gchar *str) | |||
else { | |||
fuzzy_module_ctx->servers[fuzzy_module_ctx->servers_num].port = port; | |||
fuzzy_module_ctx->servers[fuzzy_module_ctx->servers_num].name = name; | |||
memcpy (&fuzzy_module_ctx->servers[fuzzy_module_ctx->servers_num].addr, hent->h_addr, sizeof (struct in_addr)); | |||
memcpy (&fuzzy_module_ctx->servers[fuzzy_module_ctx->servers_num].addr, &addr, sizeof (struct in_addr)); | |||
fuzzy_module_ctx->servers_num++; | |||
} | |||
@@ -1427,23 +1427,24 @@ lua_regexp_match (lua_State *L) | |||
struct worker_task *task; | |||
const gchar *re_text; | |||
struct rspamd_regexp *re; | |||
gint r; | |||
gint r = 0; | |||
luaL_argcheck (L, ud != NULL, 1, "'task' expected"); | |||
task = *((struct worker_task **)ud); | |||
task = ud ? *((struct worker_task **)ud) : NULL; | |||
re_text = luaL_checkstring (L, 2); | |||
/* This is a regexp */ | |||
if ((re = re_cache_check (re_text, task->cfg->cfg_pool)) == NULL) { | |||
re = parse_regexp (task->cfg->cfg_pool, (gchar *)re_text, task->cfg->raw_mode); | |||
if (re == NULL) { | |||
msg_warn ("cannot compile regexp for function"); | |||
return FALSE; | |||
if (task != NULL) { | |||
if ((re = re_cache_check (re_text, task->cfg->cfg_pool)) == NULL) { | |||
re = parse_regexp (task->cfg->cfg_pool, (gchar *)re_text, task->cfg->raw_mode); | |||
if (re == NULL) { | |||
msg_warn ("cannot compile regexp for function"); | |||
return FALSE; | |||
} | |||
re_cache_add ((gchar *)re_text, re, task->cfg->cfg_pool); | |||
} | |||
re_cache_add ((gchar *)re_text, re, task->cfg->cfg_pool); | |||
r = process_regexp (re, task, NULL, 0, NULL); | |||
} | |||
r = process_regexp (re, task, NULL, 0, NULL); | |||
lua_pushboolean (L, r == 1); | |||
return 1; |
@@ -528,7 +528,7 @@ format_surbl_request (memory_pool_t * pool, f_str_t * hostname, struct suffix_it | |||
} | |||
else if (is_numeric && dots_num == 0) { | |||
/* This is number */ | |||
if ((suffix->options & SURBL_OPTION_NOIP) != 0) { | |||
if (suffix != NULL && (suffix->options & SURBL_OPTION_NOIP) != 0) { | |||
/* Ignore such requests */ | |||
msg_info ("ignore request of ip url for list %s", suffix->symbol); | |||
return NULL; |
@@ -783,10 +783,12 @@ parse_uri (struct uri *uri, gchar *uristring, memory_pool_t * pool) | |||
prefix_end = host_end + 1; | |||
} | |||
if (uri->ipv6) | |||
if (uri->ipv6 && rbracket != NULL) { | |||
host_end = rbracket + strcspn (rbracket, ":/?"); | |||
else | |||
} | |||
else { | |||
host_end = prefix_end + strcspn (prefix_end, ":/?"); | |||
} | |||
if (uri->ipv6) { | |||
addrlen = rbracket - lbracket - 1; |