diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-11-16 10:16:56 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-11-16 10:16:56 +0000 |
commit | d302edad6a90062424df6883b0df9a3cb9325870 (patch) | |
tree | 678699f23ccf8ef72366aff784944b90e3d3a0fa /src | |
parent | 3cb9102e94d6e3017c9573e2d778ac49a5de64fe (diff) | |
download | rspamd-d302edad6a90062424df6883b0df9a3cb9325870.tar.gz rspamd-d302edad6a90062424df6883b0df9a3cb9325870.zip |
[Minor] Add sanity checks for bayes probability
Diffstat (limited to 'src')
-rw-r--r-- | src/libstat/classifiers/bayes.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libstat/classifiers/bayes.c b/src/libstat/classifiers/bayes.c index 5295e018b..ee2125457 100644 --- a/src/libstat/classifiers/bayes.c +++ b/src/libstat/classifiers/bayes.c @@ -430,6 +430,19 @@ bayes_classify (struct rspamd_classifier * ctx, (final_prob - 0.5) * 200.); final_prob = rspamd_normalize_probability (final_prob, 0.5); g_assert (st != NULL); + + if (final_prob > 1 || final_prob < 0) { + msg_err_bayes ("internal error: probability %f is outside of the " + "allowed range [0..1]", final_prob); + + if (final_prob > 1) { + final_prob = 1.0; + } + else { + final_prob = 0.0; + } + } + rspamd_task_insert_result (task, st->stcf->symbol, final_prob, |