diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-02-19 16:24:17 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-02-19 16:24:17 +0300 |
commit | e0593fbd3b6d9c39ad7891387fc6a0faa4eea29c (patch) | |
tree | 98aef416013adf9b2c0a586a1fde38f777b6e1e6 /src | |
parent | fe1ab59efe607dfb6ee60f7bc590286909567cba (diff) | |
download | rspamd-e0593fbd3b6d9c39ad7891387fc6a0faa4eea29c.tar.gz rspamd-e0593fbd3b6d9c39ad7891387fc6a0faa4eea29c.zip |
* Add ability to save symbols that are inside composites with '-' flag.
Remove warnings from rspamc.
Add new rules [1]
Submitted by: Victor Ustugov [1]
Diffstat (limited to 'src')
-rw-r--r-- | src/client/rspamc.c | 18 | ||||
-rw-r--r-- | src/dns.c | 8 | ||||
-rw-r--r-- | src/filter.c | 22 |
3 files changed, 31 insertions, 17 deletions
diff --git a/src/client/rspamc.c b/src/client/rspamc.c index ab6ba5ad7..ceb76169a 100644 --- a/src/client/rspamc.c +++ b/src/client/rspamc.c @@ -161,16 +161,16 @@ show_metric_result (gpointer key, gpointer value, gpointer ud) gboolean first; if (metric->is_skipped) { - PRINT_FUNC ("\n%s: Skipped\n", key); + PRINT_FUNC ("\n%s: Skipped\n", (const gchar *)key); } else { if (tty) { - PRINT_FUNC ("\n\033[1m%s:\033[0m %s [ %.2f / %.2f ]\n", key, + PRINT_FUNC ("\n\033[1m%s:\033[0m %s [ %.2f / %.2f ]\n", (const gchar *)key, metric->score > metric->required_score ? "True" : "False", metric->score, metric->required_score); } else { - PRINT_FUNC ("\n%s: %s [ %.2f / %.2f ]\n", key, + PRINT_FUNC ("\n%s: %s [ %.2f / %.2f ]\n", (const gchar *)key, metric->score > metric->required_score ? "True" : "False", metric->score, metric->required_score); } @@ -205,10 +205,10 @@ show_metric_result (gpointer key, gpointer value, gpointer ud) cur = g_list_first (s->options); while (cur) { if (cur->next) { - PRINT_FUNC ("%s,", cur->data); + PRINT_FUNC ("%s,", (const gchar *)cur->data); } else { - PRINT_FUNC ("%s", cur->data); + PRINT_FUNC ("%s", (const gchar *)cur->data); } cur = g_list_next (cur); } @@ -231,10 +231,10 @@ show_metric_result (gpointer key, gpointer value, gpointer ud) cur = g_list_first (s->options); while (cur) { if (cur->next) { - PRINT_FUNC ("%s,", cur->data); + PRINT_FUNC ("%s,", (const gchar *)cur->data); } else { - PRINT_FUNC ("%s)", cur->data); + PRINT_FUNC ("%s)", (const gchar *)cur->data); } cur = g_list_next (cur); } @@ -268,10 +268,10 @@ print_rspamd_result (struct rspamd_result *res) PRINT_FUNC ("\n"); while (g_hash_table_iter_next (&it, &k, &v)) { if (tty) { - PRINT_FUNC ("\033[1m%s:\033[0m %s\n", k, v); + PRINT_FUNC ("\033[1m%s:\033[0m %s\n", (const gchar *)k, (const gchar *)v); } else { - PRINT_FUNC ("%s: %s\n", k, v); + PRINT_FUNC ("%s: %s\n", (const gchar *)k, (const gchar *)v); } } PRINT_FUNC ("\n"); @@ -874,6 +874,10 @@ dns_parse_rr (guint8 *in, union rspamd_reply_element *elt, guint8 **pos, struct p += datalen; } else { + if (p - *pos > *remain - sizeof (guint16) * 3) { + msg_info ("stripped dns reply while reading SRV record"); + return -1; + } GET16 (elt->srv.priority); GET16 (elt->srv.weight); GET16 (elt->srv.port); @@ -894,10 +898,6 @@ dns_parse_rr (guint8 *in, union rspamd_reply_element *elt, guint8 **pos, struct return 1; } return 0; - -err: - msg_info ("incomplete RR, only %d bytes remain, packet length %d", (gint)*remain, (gint)(*pos - in)); - return -1; } static struct rspamd_dns_reply * diff --git a/src/filter.c b/src/filter.c index 93f51d763..4b8585a7c 100644 --- a/src/filter.c +++ b/src/filter.c @@ -335,6 +335,7 @@ struct composites_data { struct symbol_remove_data { struct symbol *ms; gboolean remove_weight; + gboolean remove_symbol; }; static gint @@ -364,7 +365,7 @@ composites_foreach_callback (gpointer key, gpointer value, void *data) if (expr->type == EXPR_STR) { /* Find corresponding symbol */ sym = expr->content.operand; - if (*sym == '~') { + if (*sym == '~' || *sym == '-') { sym ++; } if (g_hash_table_lookup (cd->metric_res->symbols, sym) == NULL) { @@ -412,7 +413,7 @@ composites_foreach_callback (gpointer key, gpointer value, void *data) r = rspamd_snprintf (logbuf, sizeof (logbuf), "<%s>, insert symbol %s instead of symbols: ", cd->task->message_id, key); while (s) { sym = s->data; - if (*sym == '~') { + if (*sym == '~' || *sym == '-') { ms = g_hash_table_lookup (cd->metric_res->symbols, sym + 1); } else { @@ -422,7 +423,18 @@ composites_foreach_callback (gpointer key, gpointer value, void *data) if (ms != NULL) { rd = memory_pool_alloc (cd->task->task_pool, sizeof (struct symbol_remove_data)); rd->ms = ms; - rd->remove_weight = *sym != '~'; + if (G_UNLIKELY (*sym == '~')) { + rd->remove_weight = FALSE; + rd->remove_symbol = TRUE; + } + else if (G_UNLIKELY (*sym == '-')) { + rd->remove_symbol = FALSE; + rd->remove_weight = FALSE; + } + else { + rd->remove_symbol = TRUE; + rd->remove_weight = TRUE; + } if (!g_tree_lookup (cd->symbols_to_remove, rd)) { g_tree_insert (cd->symbols_to_remove, (gpointer)ms->name, rd); } @@ -523,7 +535,9 @@ composites_remove_symbols (gpointer key, gpointer value, gpointer data) struct composites_data *cd = data; struct symbol_remove_data *rd = value; - g_hash_table_remove (cd->metric_res->symbols, key); + if (rd->remove_symbol) { + g_hash_table_remove (cd->metric_res->symbols, key); + } if (rd->remove_weight) { cd->metric_res->score -= rd->ms->score; } |