]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix parsing due to old bug revealed
authorVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 24 May 2023 13:25:18 +0000 (14:25 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 24 May 2023 13:25:38 +0000 (14:25 +0100)
src/fuzzy_storage.c
src/libserver/cfg_rcl.c
src/libserver/cfg_rcl.h

index fe916088021b4379acc1e75a985f0f582cb3fb30..33f9d40e8dac5e54d0bc11b4b6fbdd7c79851e38 100644 (file)
@@ -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)");
 
index 08d534eb3ee9df2573ff3058e57b980bdaf0ef5e..073a01126576db91b85c1113e36d3c6d35e276e2 100644 (file)
@@ -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) {
index 1a2d69c58f62a44992348b1481f4a25153b6d4d8..d7777ccc700cb571e6ca1ec972948d62bb016faf 100644 (file)
@@ -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,