commit ad2d27c: [Minor] Fix include/exclude policy

Vsevolod Stakhov vsevolod at rspamd.com
Sat Apr 8 21:07:04 UTC 2023


Author: Vsevolod Stakhov
Date: 2023-04-08 22:05:14 +0100
URL: https://github.com/rspamd/rspamd/commit/ad2d27ce7f1f66feb4d8e24cadb75da8486848b1 (HEAD -> master)

[Minor] Fix include/exclude policy

---
 src/fuzzy_storage.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index 7d19b6d2d..a6d8be896 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -783,6 +783,8 @@ rspamd_fuzzy_make_reply (struct rspamd_fuzzy_cmd *cmd,
 			session->reply.rep.v1.value = 0;
 		}
 
+		bool default_disabled = false;
+
 		{
 			khiter_t k;
 
@@ -790,10 +792,7 @@ rspamd_fuzzy_make_reply (struct rspamd_fuzzy_cmd *cmd,
 
 			if (k != kh_end(session->ctx->default_forbidden_ids)) {
 				/* Hash is from a forbidden flag by default */
-				session->reply.rep.ts = 0;
-				session->reply.rep.v1.prob = 0.0f;
-				session->reply.rep.v1.value = 0;
-				session->reply.rep.v1.flag = 0;
+				default_disabled = true;
 			}
 		}
 
@@ -812,6 +811,13 @@ rspamd_fuzzy_make_reply (struct rspamd_fuzzy_cmd *cmd,
 					session->reply.rep.v1.flag = 0;
 				}
 			}
+			else if (default_disabled) {
+				/* Hash is from a forbidden flag by default */
+				session->reply.rep.ts = 0;
+				session->reply.rep.v1.prob = 0.0f;
+				session->reply.rep.v1.value = 0;
+				session->reply.rep.v1.flag = 0;
+			}
 
 			/* We need also to encrypt reply */
 			ottery_rand_bytes (session->reply.hdr.nonce,
@@ -836,6 +842,13 @@ rspamd_fuzzy_make_reply (struct rspamd_fuzzy_cmd *cmd,
 					session->reply.hdr.mac,
 					RSPAMD_CRYPTOBOX_MODE_25519);
 		}
+		else if (default_disabled) {
+			/* Hash is from a forbidden flag by default, and there is no encryption override */
+			session->reply.rep.ts = 0;
+			session->reply.rep.v1.prob = 0.0f;
+			session->reply.rep.v1.value = 0;
+			session->reply.rep.v1.flag = 0;
+		}
 	}
 
 	rspamd_fuzzy_write_reply (session);


More information about the Commits mailing list