]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Deal with unknown weight more carefully to avoid special meaning of 0
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 15 Jan 2022 12:24:25 +0000 (12:24 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 15 Jan 2022 12:24:25 +0000 (12:24 +0000)
The special unknown weight must be NAN not 0.0

src/libserver/cfg_utils.c
src/libserver/rspamd_symcache.c

index 67ceb5df88de2dbd4b539a0009816ca358fe57f7..44cdbc84fde3e496af059467afc5ec0a7ffa0de1 100644 (file)
@@ -171,6 +171,7 @@ rspamd_config_new (enum rspamd_config_init_flags flags)
        cfg->dns_retransmits = 5;
        /* 16 sockets per DNS server */
        cfg->dns_io_per_server = 16;
+       cfg->unknown_weight = NAN;
 
        /* Add all internal actions to keep compatibility */
        for (int i = METRIC_ACTION_REJECT; i < METRIC_ACTION_MAX; i ++) {
index d1fb6867290b9e69273daf4009198aaf6666daa8..4335ada684ba6f794c1166153aa4c7882b7b8a9f 100644 (file)
@@ -1438,7 +1438,7 @@ rspamd_symcache_validate_cb (gpointer k, gpointer v, gpointer ud)
                        (SYMBOL_TYPE_NORMAL|SYMBOL_TYPE_VIRTUAL|SYMBOL_TYPE_COMPOSITE|SYMBOL_TYPE_CLASSIFIER))
                        && g_hash_table_lookup (cfg->symbols, item->symbol) == NULL) {
 
-               if (cfg->unknown_weight != 0) {
+               if (!isnan(cfg->unknown_weight)) {
 
                        skipped = FALSE;
                        item->st->weight = cfg->unknown_weight;
@@ -1448,7 +1448,8 @@ rspamd_symcache_validate_cb (gpointer k, gpointer v, gpointer ud)
                        s->weight_ptr = &item->st->weight;
                        g_hash_table_insert (cfg->symbols, item->symbol, s);
 
-                       msg_info_cache ("adding unknown symbol %s", item->symbol);
+                       msg_info_cache ("adding unknown symbol %s with weight: %.2f",
+                                       item->symbol, cfg->unknown_weight);
                        ghost = FALSE;
                }
                else {