In composite_dep_callback, atom->begin from rspamd_ftok_t is not null-terminated,
but was being passed directly to symbol_needs_second_pass() which calls
rspamd_symcache_get_symbol_flags() expecting a null-terminated C string.
This could cause incorrect symbol lookups or undefined behavior. Fix by creating
a std::string to ensure null-termination before passing to the C API.
}
/* Check if the symbol itself needs second pass */
- if (symbol_needs_second_pass(cfg, atom->begin)) {
- msg_debug_config("composite depends on second-pass symbol: %*s",
- (int) atom->len, atom->begin);
+ /* Create null-terminated string for C API (rspamd_ftok_t is not null-terminated) */
+ std::string symbol_name(atom->begin, atom->len);
+ if (symbol_needs_second_pass(cfg, symbol_name.c_str())) {
+ msg_debug_config("composite depends on second-pass symbol: %s",
+ symbol_name.c_str());
cbd->needs_second_pass = true;
}
}