From: Vsevolod Stakhov Date: Sat, 15 Oct 2016 13:44:20 +0000 (+0100) Subject: [Fix] Remove fann with incorrect layers count X-Git-Tag: 1.4.0~256 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2e2b739c50a5f887624c54a1a3cd5030e5647eee;p=rspamd.git [Fix] Remove fann with incorrect layers count --- diff --git a/src/plugins/lua/fann_scores.lua b/src/plugins/lua/fann_scores.lua index 9647fd3d3..d1564cd2e 100644 --- a/src/plugins/lua/fann_scores.lua +++ b/src/plugins/lua/fann_scores.lua @@ -311,8 +311,21 @@ local function load_fann(id) fname, err) end else - rspamd_logger.infox(rspamd_config, 'loaded fann from %s', fname) - return true + local layers = data[id].fann:get_layers() + + if not layers or #layers ~= 5 then + rspamd_logger.infox(rspamd_config, 'fann has incorrect number of layers: %s, removing', + #layers) + data[id].fann = nil + local ret,err = rspamd_util.unlink(fname) + if not ret then + rspamd_logger.errx(rspamd_config, 'cannot remove invalid fann from %s: %s', + fname, err) + end + else + rspamd_logger.infox(rspamd_config, 'loaded fann from %s', fname) + return true + end end else rspamd_logger.infox(rspamd_config, 'fann is invalid: "%s"; removing', fname)