summaryrefslogtreecommitdiffstats
path: root/src/libserver/fuzzy_backend.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-12-15 21:55:34 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-12-15 21:55:34 +0000
commit655b2644d90dfec7294f597df469e2ae3c29948a (patch)
treecda7bc96ddb2c39a2bdcf95e945673b4ed8e7214 /src/libserver/fuzzy_backend.c
parent88faa68e4e191355f01a4f8546f1d524e0dd79f1 (diff)
downloadrspamd-655b2644d90dfec7294f597df469e2ae3c29948a.tar.gz
rspamd-655b2644d90dfec7294f597df469e2ae3c29948a.zip
Fix errors processing in fuzzy check
Diffstat (limited to 'src/libserver/fuzzy_backend.c')
-rw-r--r--src/libserver/fuzzy_backend.c48
1 files changed, 31 insertions, 17 deletions
diff --git a/src/libserver/fuzzy_backend.c b/src/libserver/fuzzy_backend.c
index d525a9c56..4a59e367c 100644
--- a/src/libserver/fuzzy_backend.c
+++ b/src/libserver/fuzzy_backend.c
@@ -544,25 +544,39 @@ rspamd_fuzzy_backend_check (struct rspamd_fuzzy_backend *backend,
if (sel_id != -1) {
/* We have some id selected here */
rep.prob = (float)max_cnt / (float)RSPAMD_SHINGLE_SIZE;
- msg_debug_fuzzy_backend ("found fuzzy hash with probability %.2f", rep.prob);
- rc = rspamd_fuzzy_backend_run_stmt (backend, FALSE,
- RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID, sel_id);
- if (rc == SQLITE_OK) {
- digest = sqlite3_column_text (
- prepared_stmts[RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID].stmt, 0);
- timestamp = sqlite3_column_int64 (
- prepared_stmts[RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID].stmt, 2);
- if (time (NULL) - timestamp > expire) {
- /* Expire element */
- msg_debug_fuzzy_backend ("requested hash has been expired");
- }
- else {
- rep.value = sqlite3_column_int64 (
- prepared_stmts[RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID].stmt, 1);
- rep.flag = sqlite3_column_int (
- prepared_stmts[RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID].stmt, 3);
+
+ if (rep.prob > 0.5) {
+ msg_debug_fuzzy_backend (
+ "found fuzzy hash with probability %.2f",
+ rep.prob);
+ rc = rspamd_fuzzy_backend_run_stmt (backend, FALSE,
+ RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID, sel_id);
+ if (rc == SQLITE_OK) {
+ digest = sqlite3_column_text (
+ prepared_stmts[RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID].stmt,
+ 0);
+ timestamp = sqlite3_column_int64 (
+ prepared_stmts[RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID].stmt,
+ 2);
+ if (time (NULL) - timestamp > expire) {
+ /* Expire element */
+ msg_debug_fuzzy_backend (
+ "requested hash has been expired");
+ }
+ else {
+ rep.value = sqlite3_column_int64 (
+ prepared_stmts[RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID].stmt,
+ 1);
+ rep.flag = sqlite3_column_int (
+ prepared_stmts[RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID].stmt,
+ 3);
+ }
}
}
+ else {
+ /* Otherwise we assume that as error */
+ rep.value = 0;
+ }
rspamd_fuzzy_backend_cleanup_stmt (backend,
RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID);