aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/fuzzy_backend.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-24 14:44:26 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-24 14:44:26 +0000
commit54918933b03a19664a7901aca13c03073a7594ef (patch)
treecb6182c19519eaf24294582876d0183477085467 /src/libserver/fuzzy_backend.c
parentc2d682793739cb332728f477abdc3848338b8d0e (diff)
downloadrspamd-54918933b03a19664a7901aca13c03073a7594ef.tar.gz
rspamd-54918933b03a19664a7901aca13c03073a7594ef.zip
Fix critical issue in adding fuzzy hashes
Diffstat (limited to 'src/libserver/fuzzy_backend.c')
-rw-r--r--src/libserver/fuzzy_backend.c68
1 files changed, 33 insertions, 35 deletions
diff --git a/src/libserver/fuzzy_backend.c b/src/libserver/fuzzy_backend.c
index 611d212c4..3105fdf11 100644
--- a/src/libserver/fuzzy_backend.c
+++ b/src/libserver/fuzzy_backend.c
@@ -607,47 +607,45 @@ rspamd_fuzzy_backend_add (struct rspamd_fuzzy_backend *backend,
}
}
else {
- if (rc == SQLITE_OK) {
- rc = rspamd_fuzzy_backend_run_stmt (backend, FALSE,
- RSPAMD_FUZZY_BACKEND_INSERT,
- (gint) cmd->flag,
- cmd->digest,
- (gint64) cmd->value,
- (gint64) time (NULL));
+ rc = rspamd_fuzzy_backend_run_stmt (backend, FALSE,
+ RSPAMD_FUZZY_BACKEND_INSERT,
+ (gint) cmd->flag,
+ cmd->digest,
+ (gint64) cmd->value,
+ (gint64) time (NULL));
- if (rc == SQLITE_OK) {
- if (cmd->shingles_count > 0) {
- id = sqlite3_last_insert_rowid (backend->db);
- shcmd = (const struct rspamd_fuzzy_shingle_cmd *) cmd;
-
- for (i = 0; i < RSPAMD_SHINGLE_SIZE; i++) {
- rc = rspamd_fuzzy_backend_run_stmt (backend, TRUE,
- RSPAMD_FUZZY_BACKEND_INSERT_SHINGLE,
- shcmd->sgl.hashes[i], i, id);
- msg_debug_fuzzy_backend ("add shingle %d -> %L: %L",
- i,
+ if (rc == SQLITE_OK) {
+ if (cmd->shingles_count > 0) {
+ id = sqlite3_last_insert_rowid (backend->db);
+ shcmd = (const struct rspamd_fuzzy_shingle_cmd *) cmd;
+
+ for (i = 0; i < RSPAMD_SHINGLE_SIZE; i++) {
+ rc = rspamd_fuzzy_backend_run_stmt (backend, TRUE,
+ RSPAMD_FUZZY_BACKEND_INSERT_SHINGLE,
+ shcmd->sgl.hashes[i], i, id);
+ msg_debug_fuzzy_backend ("add shingle %d -> %L: %L",
+ i,
+ shcmd->sgl.hashes[i],
+ id);
+
+ if (rc != SQLITE_OK) {
+ msg_warn_fuzzy_backend ("cannot add shingle %d -> "
+ "%L: %L: %s", i,
shcmd->sgl.hashes[i],
- id);
-
- if (rc != SQLITE_OK) {
- msg_warn_fuzzy_backend ("cannot add shingle %d -> "
- "%L: %L: %s", i,
- shcmd->sgl.hashes[i],
- id, sqlite3_errmsg (backend->db));
- }
+ id, sqlite3_errmsg (backend->db));
}
}
}
- else {
- msg_warn_fuzzy_backend ("cannot add hash to %d -> "
- "%*xs: %s", (gint)cmd->flag,
- (gint)sizeof (cmd->digest), cmd->digest,
- sqlite3_errmsg (backend->db));
- }
-
- rspamd_fuzzy_backend_cleanup_stmt (backend,
- RSPAMD_FUZZY_BACKEND_INSERT);
}
+ else {
+ msg_warn_fuzzy_backend ("cannot add hash to %d -> "
+ "%*xs: %s", (gint)cmd->flag,
+ (gint)sizeof (cmd->digest), cmd->digest,
+ sqlite3_errmsg (backend->db));
+ }
+
+ rspamd_fuzzy_backend_cleanup_stmt (backend,
+ RSPAMD_FUZZY_BACKEND_INSERT);
}
if (rc == SQLITE_OK) {