gint r;
if (s && val) {
+ if (s->opts_len < 0) {
+ /* Cannot add more options, give up */
+ msg_debug_task ("cannot add more options to symbol %s when adding option %s",
+ s->name, val);
+ return FALSE;
+ }
+
if (!s->options) {
s->options = kh_init (rspamd_options_hash);
}
vlen = strlen (val);
+ if (vlen + s->opts_len > task->cfg->max_opts_len) {
+ /* Add truncated option */
+ msg_info_task ("cannot add more options to symbol %s when adding option %s",
+ s->name, val);
+ val = "...";
+ vlen = 3;
+ s->opts_len = -1;
+ }
+
if (rspamd_fast_utf8_validate (val, vlen) != 0) {
opt_cpy = rspamd_str_make_utf_valid (val, vlen, &vlen,
task->task_pool);
ret = TRUE;
}
+
+ if (ret && s->opts_len >= 0) {
+ s->opts_len += vlen;
+ }
}
else if (!val) {
ret = TRUE;
struct rspamd_symbol_option *opts_head; /**< head of linked list of options */
const gchar *name;
struct rspamd_symbol *sym; /**< symbol configuration */
+ gssize opts_len; /**< total size of all options (negative if truncated option is added) */
guint nshots;
enum rspamd_symbol_result_flags flags;
};
guint full_gc_iters; /**< iterations between full gc cycle */
guint max_lua_urls; /**< maximum number of urls to be passed to Lua */
guint max_blas_threads; /**< maximum threads for openblas when learning ANN */
+ guint max_opts_len; /**< maximum length for all options for a symbol */
GList *classify_headers; /**< list of headers using for statistics */
struct module_s **compiled_modules; /**< list of compiled C modules */
G_STRUCT_OFFSET (struct rspamd_config, max_blas_threads),
RSPAMD_CL_FLAG_INT_32,
"Maximum number of Blas threads for learning neural networks (default: 1)");
+ rspamd_rcl_add_default_handler (sub,
+ "max_opts_len",
+ rspamd_rcl_parse_struct_integer,
+ G_STRUCT_OFFSET (struct rspamd_config, max_opts_len),
+ RSPAMD_CL_FLAG_INT_32,
+ "Maximum size of all options for a single symbol (default: 4096)");
rspamd_rcl_add_default_handler (sub,
"events_backend",
rspamd_rcl_parse_struct_string,
cfg->cache_reload_time = 30.0;
cfg->max_lua_urls = 1024;
cfg->max_blas_threads = 1;
+ cfg->max_opts_len = 4096;
/* Default log line */
cfg->log_format_str = "id: <$mid>,$if_qid{ qid: <$>,}$if_ip{ ip: $,}"