commit 1c11ff3: [Fix] Fix parsing due to old bug revealed

Vsevolod Stakhov vsevolod at rspamd.com
Wed May 24 13:28:03 UTC 2023


Author: Vsevolod Stakhov
Date: 2023-05-24 14:25:18 +0100
URL: https://github.com/rspamd/rspamd/commit/1c11ff329d2532f3bd2f0b9af1d6a3a4d6079fc4 (HEAD -> master)

[Fix] Fix parsing due to old bug revealed

---
 src/fuzzy_storage.c     | 10 +++++-----
 src/libserver/cfg_rcl.c |  2 +-
 src/libserver/cfg_rcl.h |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index fe9160880..33f9d40e8 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -2296,7 +2296,7 @@ fuzzy_parse_ids (rspamd_mempool_t *pool,
 	struct rspamd_rcl_struct_parser *pd = (struct rspamd_rcl_struct_parser *)ud;
 	khash_t(fuzzy_key_ids_set) *target;
 
-	target = (khash_t(fuzzy_key_ids_set) *)pd->user_struct;
+	target = *(khash_t(fuzzy_key_ids_set) **)((gchar *)pd->user_struct + pd->offset);
 
 	if (ucl_object_type (obj) == UCL_ARRAY) {
 		const ucl_object_t *cur;
@@ -2543,8 +2543,8 @@ init_fuzzy (struct rspamd_config *cfg)
 			type,
 			"forbidden_ids",
 			fuzzy_parse_ids,
-			ctx->default_forbidden_ids,
-			0,
+			ctx,
+			G_STRUCT_OFFSET(struct rspamd_fuzzy_storage_ctx, default_forbidden_ids),
 			0,
 			"Deny specific flags by default");
 
@@ -2552,8 +2552,8 @@ init_fuzzy (struct rspamd_config *cfg)
 		type,
 		"weak_ids",
 		fuzzy_parse_ids,
-		ctx->weak_ids,
-		0,
+		ctx,
+		G_STRUCT_OFFSET(struct rspamd_fuzzy_storage_ctx, weak_ids),
 		0,
 		"Treat these flags as weak (i.e. they do not overwrite strong flags)");
 
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 08d534eb3..073a01126 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -759,7 +759,7 @@ rspamd_rcl_worker_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
 
 		while ((cur = ucl_object_iterate_full (it, UCL_ITERATE_EXPLICIT)) != NULL) {
 			srch.name = ucl_object_key (cur);
-			srch.ptr = wrk->ctx; /* XXX: is it valid? */
+			srch.ptr = wrk->ctx; /* XXX: is it valid? Update! no, it is not valid, omfg... */
 			whandler = g_hash_table_lookup (wparser->parsers, &srch);
 
 			if (whandler != NULL) {
diff --git a/src/libserver/cfg_rcl.h b/src/libserver/cfg_rcl.h
index 1a2d69c58..d7777ccc7 100644
--- a/src/libserver/cfg_rcl.h
+++ b/src/libserver/cfg_rcl.h
@@ -363,7 +363,7 @@ gboolean rspamd_rcl_parse_struct_ucl (rspamd_mempool_t *pool,
  * @param type type of worker (GQuark)
  * @param name name of option
  * @param handler handler of option
- * @param target opaque target structure
+ * @param target opaque target structure, note it **MUST** be worker ctx due to some reasons I don't really remember
  * @param offset offset inside a structure
  */
 void rspamd_rcl_register_worker_option (struct rspamd_config *cfg,


More information about the Commits mailing list