When rspamd_config_add_symbol was called for an existing symbol without
a score (NAN), line 1811 unconditionally replaced all flags, clearing
RSPAMD_SYMBOL_FLAG_UNSCORED. This caused Lua-registered scores to be
ignored: if a symbol appeared in config (e.g. groups.conf) without a
score, the UNSCORED flag was lost, and the Lua score-setting block in
lua_config_register_symbol_from_table was skipped, leaving score at 0.
Now flags are updated correctly in both cases:
- Real score provided: flags fully replaced with UNSCORED cleared
- NAN score: flags updated but UNSCORED preserved from existing symbol
Also initialize score to NAN in lua_config_set_metric_symbol to avoid
passing uninitialized stack garbage to rspamd_config_add_symbol.
*sym_def->weight_ptr = score;
sym_def->score = score;
sym_def->priority = priority;
- sym_def->flags &= ~RSPAMD_SYMBOL_FLAG_UNSCORED;
+ sym_def->flags = flags & ~RSPAMD_SYMBOL_FLAG_UNSCORED;
+ }
+ else {
+ /* Preserve UNSCORED flag when not setting a real score */
+ sym_def->flags = flags | (sym_def->flags & RSPAMD_SYMBOL_FLAG_UNSCORED);
}
-
- sym_def->flags = flags;
if (nshots != 0) {
sym_def->nshots = nshots;
struct rspamd_config *cfg = lua_check_config(L, 1);
const char *description = NULL,
*group = NULL, *name = NULL, *flags_str = NULL;
- double score;
+ double score = NAN;
gboolean one_shot = FALSE, one_param = FALSE;
GError *err = NULL;
double priority = 0.0;