aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libmime/filter.c1
-rw-r--r--src/libstat/classifiers/bayes.c12
-rw-r--r--src/lua/lua_config.c17
-rw-r--r--src/lua/lua_task.c41
-rw-r--r--src/plugins/dkim_check.c8
-rw-r--r--src/plugins/spf.c9
-rw-r--r--src/plugins/surbl.c14
7 files changed, 40 insertions, 62 deletions
diff --git a/src/libmime/filter.c b/src/libmime/filter.c
index 686e30ad7..c9f40ea1d 100644
--- a/src/libmime/filter.c
+++ b/src/libmime/filter.c
@@ -80,7 +80,6 @@ insert_metric_result (struct rspamd_task *task,
{
struct metric_result *metric_res;
struct symbol *s = NULL;
- char *opt_cpy;
gdouble w, *gr_score = NULL;
struct rspamd_symbol_def *sdef;
struct rspamd_symbols_group *gr = NULL;
diff --git a/src/libstat/classifiers/bayes.c b/src/libstat/classifiers/bayes.c
index 07fe6cc86..98b3fd6ca 100644
--- a/src/libstat/classifiers/bayes.c
+++ b/src/libstat/classifiers/bayes.c
@@ -181,13 +181,12 @@ bayes_classify (struct rspamd_classifier * ctx,
struct rspamd_task *task)
{
double final_prob, h, s, *pprob;
- char *sumbuf;
+ gchar sumbuf[32];
struct rspamd_statfile *st = NULL;
struct bayes_task_closure cl;
rspamd_token_t *tok;
guint i;
gint id;
- GList *cur;
g_assert (ctx != NULL);
g_assert (tokens != NULL);
@@ -262,9 +261,6 @@ bayes_classify (struct rspamd_classifier * ctx,
rspamd_mempool_set_variable (task->task_pool, "bayes_prob", pprob, NULL);
if (cl.processed_tokens > 0 && fabs (final_prob - 0.5) > 0.05) {
-
- sumbuf = rspamd_mempool_alloc (task->task_pool, 32);
-
/* Now we can have exactly one HAM and exactly one SPAM statfiles per classifier */
for (i = 0; i < ctx->statfiles_ids->len; i++) {
id = g_array_index (ctx->statfiles_ids, gint, i);
@@ -287,14 +283,14 @@ bayes_classify (struct rspamd_classifier * ctx,
* Bayes p is from 0.5 to 1.0, but confidence is from 0 to 1, so
* we need to rescale it to display correctly
*/
- rspamd_snprintf (sumbuf, 32, "%.2f%%", (final_prob - 0.5) * 200.);
+ rspamd_snprintf (sumbuf, sizeof (sumbuf), "%.2f%%",
+ (final_prob - 0.5) * 200.);
final_prob = rspamd_normalize_probability (final_prob, 0.5);
g_assert (st != NULL);
- cur = g_list_prepend (NULL, sumbuf);
rspamd_task_insert_result (task,
st->stcf->symbol,
final_prob,
- cur);
+ sumbuf);
}
return TRUE;
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index 7c2b84609..48bb36e6d 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -808,6 +808,7 @@ lua_metric_symbol_callback (struct rspamd_task *task, gpointer ud)
gint level = lua_gettop (cd->L), nresults, err_idx;
lua_State *L = cd->L;
GString *tb;
+ struct symbol *s;
lua_pushcfunction (L, &rspamd_lua_traceback);
err_idx = lua_gettop (L);
@@ -837,7 +838,6 @@ lua_metric_symbol_callback (struct rspamd_task *task, gpointer ud)
if (nresults >= 1) {
/* Function returned boolean, so maybe we need to insert result? */
gint res = 0;
- GList *opts = NULL;
gint i;
gdouble flag = 1.0;
@@ -860,17 +860,18 @@ lua_metric_symbol_callback (struct rspamd_task *task, gpointer ud)
flag = res;
}
- for (i = lua_gettop (L); i >= level + first_opt; i--) {
- if (lua_type (L, i) == LUA_TSTRING) {
- const char *opt = lua_tostring (L, i);
+ s = rspamd_task_insert_result (task, cd->symbol, flag, NULL);
- opts = g_list_prepend (opts,
- rspamd_mempool_strdup (task->task_pool,
- opt));
+ if (s) {
+ for (i = lua_gettop (L); i >= level + first_opt; i--) {
+ if (lua_type (L, i) == LUA_TSTRING) {
+ const char *opt = lua_tostring (L, i);
+
+ rspamd_task_add_result_option (task, s, opt);
+ }
}
}
- rspamd_task_insert_result (task, cd->symbol, flag, opts);
}
lua_pop (L, nresults);
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 8f28bb97b..7693fe48e 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -1018,7 +1018,7 @@ lua_task_insert_result (lua_State * L)
struct rspamd_task *task = lua_check_task (L, 1);
const gchar *symbol_name, *param;
double flag;
- GList *params = NULL;
+ struct symbol *s;
gint i, top;
if (task != NULL) {
@@ -1026,35 +1026,30 @@ lua_task_insert_result (lua_State * L)
rspamd_mempool_strdup (task->task_pool, luaL_checkstring (L, 2));
flag = luaL_checknumber (L, 3);
top = lua_gettop (L);
+ s = rspamd_task_insert_result (task, symbol_name, flag, NULL);
+
/* Get additional options */
- for (i = 4; i <= top; i++) {
- if (lua_type (L, i) == LUA_TSTRING) {
- param = luaL_checkstring (L, i);
- params =
- g_list_prepend (params,
- rspamd_mempool_strdup (task->task_pool, param));
- }
- else if (lua_type (L, i) == LUA_TTABLE) {
- lua_pushvalue (L, i);
- lua_pushnil (L);
+ if (s) {
+ for (i = 4; i <= top; i++) {
+ if (lua_type (L, i) == LUA_TSTRING) {
+ param = luaL_checkstring (L, i);
+ rspamd_task_add_result_option (task, s, param);
+ }
+ else if (lua_type (L, i) == LUA_TTABLE) {
+ lua_pushvalue (L, i);
+ lua_pushnil (L);
+
+ while (lua_next (L, -2)) {
+ param = lua_tostring (L, -1);
+ rspamd_task_add_result_option (task, s, param);
+ lua_pop (L, 1);
+ }
- while (lua_next (L, -2)) {
- param = lua_tostring (L, -1);
- params = g_list_prepend (params,
- rspamd_mempool_strdup (task->task_pool,
- param));
lua_pop (L, 1);
}
-
- lua_pop (L, 1);
}
}
- if (params) {
- params = g_list_reverse (params);
- }
-
- rspamd_task_insert_result (task, symbol_name, flag, params);
}
else {
return luaL_error (L, "invalid arguments");
diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c
index 71214b2bc..5d30cdcb3 100644
--- a/src/plugins/dkim_check.c
+++ b/src/plugins/dkim_check.c
@@ -616,8 +616,8 @@ dkim_module_check (struct dkim_check_result *res)
if (all_done) {
DL_FOREACH (first, cur) {
const gchar *symbol = NULL;
- GList *messages = NULL;
int symbol_weight = 1;
+
if (cur->ctx == NULL) {
continue;
}
@@ -635,14 +635,12 @@ dkim_module_check (struct dkim_check_result *res)
else if (cur->res == DKIM_TRYAGAIN) {
symbol = dkim_module_ctx->symbol_tempfail;
}
+
if (symbol != NULL) {
- messages = g_list_prepend (messages,
- rspamd_mempool_strdup (cur->task->task_pool,
- rspamd_dkim_get_domain (cur->ctx)));
rspamd_task_insert_result (cur->task,
symbol,
symbol_weight,
- messages);
+ rspamd_dkim_get_domain (cur->ctx));
}
}
rspamd_session_watcher_pop (res->task->s, res->w);
diff --git a/src/plugins/spf.c b/src/plugins/spf.c
index 98ca09c37..d7b76e003 100644
--- a/src/plugins/spf.c
+++ b/src/plugins/spf.c
@@ -347,7 +347,6 @@ spf_check_element (struct spf_resolved *rec, struct spf_addr *addr,
gchar *spf_result;
guint af, mask, bmask, addrlen;
const gchar *spf_message, *spf_symbol;
- GList *opts = NULL;
if (task->from_addr == NULL) {
return FALSE;
@@ -406,7 +405,6 @@ spf_check_element (struct spf_resolved *rec, struct spf_addr *addr,
if (res) {
spf_result = rspamd_mempool_alloc (task->task_pool,
strlen (addr->spf_string) + 2);
- opts = g_list_prepend (opts, spf_result);
switch (addr->mech) {
case SPF_FAIL:
@@ -464,7 +462,7 @@ spf_check_element (struct spf_resolved *rec, struct spf_addr *addr,
rspamd_task_insert_result (task,
spf_symbol,
1,
- opts);
+ spf_result);
ucl_object_insert_key (task->messages,
ucl_object_fromstring (spf_message), "spf", 0,
false);
@@ -575,15 +573,12 @@ spf_symbol_callback (struct rspamd_task *task, void *unused)
w = rspamd_session_get_watcher (task->s);
if (!rspamd_spf_resolve (task, spf_plugin_callback, w)) {
- GList *opts = NULL;
-
- opts = g_list_prepend (opts, "(SPF): spf DNS fail");
msg_info_task ("cannot make spf request for [%s]",
task->message_id);
rspamd_task_insert_result (task,
spf_module_ctx->symbol_dnsfail,
1,
- opts);
+ "(SPF): spf DNS fail");
}
else {
rspamd_session_watcher_push (task->s);
diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c
index 6dea0b939..32c002d96 100644
--- a/src/plugins/surbl.c
+++ b/src/plugins/surbl.c
@@ -1137,9 +1137,7 @@ process_dns_results (struct rspamd_task *task,
task->message_id,
url, suffix->suffix,
bit->bit);
- rspamd_task_insert_result (task, bit->symbol, 1,
- g_list_prepend (NULL,
- rspamd_mempool_strdup (task->task_pool, url)));
+ rspamd_task_insert_result (task, bit->symbol, 1, url);
got_result = TRUE;
}
}
@@ -1158,9 +1156,7 @@ process_dns_results (struct rspamd_task *task,
task->message_id,
url, suffix->suffix,
bit->bit);
- rspamd_task_insert_result (task, bit->symbol, 1,
- g_list_prepend (NULL,
- rspamd_mempool_strdup (task->task_pool, url)));
+ rspamd_task_insert_result (task, bit->symbol, 1, url);
}
}
}
@@ -1170,9 +1166,7 @@ process_dns_results (struct rspamd_task *task,
msg_info_task ("<%s> domain [%s] is in surbl %s",
task->message_id,
url, suffix->suffix);
- rspamd_task_insert_result (task, suffix->symbol, 1,
- g_list_prepend (NULL,
- rspamd_mempool_strdup (task->task_pool, url)));
+ rspamd_task_insert_result (task, suffix->symbol, 1, url);
}
else {
ina.s_addr = addr;
@@ -1456,7 +1450,7 @@ surbl_tree_url_callback (gpointer key, gpointer value, void *data)
rspamd_task_insert_result (param->task,
surbl_module_ctx->redirector_symbol,
1,
- g_list_prepend (NULL, found_tld));
+ found_tld);
}
register_redirector_call (url,