diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-27 15:32:00 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-27 15:32:00 +0100 |
commit | 52b516b6aa93fef63979404bd581abf4ec587feb (patch) | |
tree | a29b61522998ed6b01509457a8832bb5d1faf6e0 /src/libstat | |
parent | 88f30e7b837e445c5942e43abdee3a451b29f7ff (diff) | |
download | rspamd-52b516b6aa93fef63979404bd581abf4ec587feb.tar.gz rspamd-52b516b6aa93fef63979404bd581abf4ec587feb.zip |
Fix issues with compatibility tokenization.
Diffstat (limited to 'src/libstat')
-rw-r--r-- | src/libstat/stat_process.c | 27 | ||||
-rw-r--r-- | src/libstat/tokenizers/osb.c | 10 |
2 files changed, 24 insertions, 13 deletions
diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c index 3ec579049..141b2dfd5 100644 --- a/src/libstat/stat_process.c +++ b/src/libstat/stat_process.c @@ -157,6 +157,7 @@ rspamd_stat_get_tokenizer_runtime (struct rspamd_tokenizer_config *cf, tok = rspamd_mempool_alloc (task->task_pool, sizeof (*tok)); tok->tokenizer = rspamd_stat_get_tokenizer (name); + tok->tkcf = cf; if (tok->tokenizer == NULL) { return NULL; @@ -168,7 +169,6 @@ rspamd_stat_get_tokenizer_runtime (struct rspamd_tokenizer_config *cf, tok->config = conf; tok->conf_len = conf_len; - tok->tkcf = cf; tok->tokens = g_tree_new (token_node_compare_func); rspamd_mempool_add_destructor (task->task_pool, (rspamd_mempool_destruct_t)g_tree_destroy, tok->tokens); @@ -295,13 +295,17 @@ rspamd_stat_preprocess (struct rspamd_stat_ctx *st_ctx, } cl_runtime->clcf = clcf; + bk = rspamd_stat_get_backend (clcf->backend); if (bk == NULL) { - msg_warn ("backend of type %s is not defined", clcf->backend); - cur = g_list_next (cur); - continue; + g_set_error (err, rspamd_stat_quark(), 500, + "backend %s is not defined", clcf->backend); + g_list_free (cl_runtimes); + return NULL; } + cl_runtime->backend = bk; + curst = st_list; while (curst != NULL) { stcf = (struct rspamd_statfile_config *)curst->data; @@ -348,15 +352,14 @@ rspamd_stat_preprocess (struct rspamd_stat_ctx *st_ctx, return NULL; } } - else { - if (!cl_runtime->tok->tokenizer->compatible_config ( - cl_runtime->tok, tok_config, conf_len)) { - g_set_error (err, rspamd_stat_quark(), 500, - "incompatible tokenizer for statfile %s", stcf->symbol); - g_list_free (cl_runtimes); - return NULL; - } + if (!cl_runtime->tok->tokenizer->compatible_config ( + cl_runtime->tok, tok_config, conf_len)) { + g_set_error (err, rspamd_stat_quark(), 500, + "incompatible tokenizer for statfile %s", stcf->symbol); + g_list_free (cl_runtimes); + + return NULL; } st_runtime = rspamd_mempool_alloc0 (task->task_pool, diff --git a/src/libstat/tokenizers/osb.c b/src/libstat/tokenizers/osb.c index 40dec0d82..bbb2656c2 100644 --- a/src/libstat/tokenizers/osb.c +++ b/src/libstat/tokenizers/osb.c @@ -347,8 +347,16 @@ rspamd_tokenizer_osb_load_config (rspamd_mempool_t *pool, { struct rspamd_osb_tokenizer_config *osb_cf; - if (ptr == NULL) { + if (ptr == NULL || len == 0) { osb_cf = rspamd_tokenizer_osb_config_from_ucl (pool, rt->tkcf->opts); + + if (osb_cf->ht != RSPAMD_OSB_HASH_COMPAT) { + /* Trying to load incompatible configuration */ + msg_err ("cannot load tokenizer configuration from a legacy statfile," + " maybe you have forgotten to set 'compat' option in the " + "tokenizer configuration"); + return FALSE; + } } else { g_assert (len == sizeof (*osb_cf)); |