aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmime/scan_result.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-12-13 15:10:01 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-12-13 15:10:23 +0000
commit545463577aabc27c755db78a8ad5f931b9f3fc88 (patch)
treeddbe71c129ae6f934d30674d1258cc5c8394c97c /src/libmime/scan_result.c
parentda195bf5f1bf1e363d3bffdbf94bde32f9c5f60a (diff)
downloadrspamd-545463577aabc27c755db78a8ad5f931b9f3fc88.tar.gz
rspamd-545463577aabc27c755db78a8ad5f931b9f3fc88.zip
[Fix] Limit size of symbols options by max_opts_len option
Diffstat (limited to 'src/libmime/scan_result.c')
-rw-r--r--src/libmime/scan_result.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libmime/scan_result.c b/src/libmime/scan_result.c
index c7c2647d2..5ded3ac57 100644
--- a/src/libmime/scan_result.c
+++ b/src/libmime/scan_result.c
@@ -523,12 +523,28 @@ rspamd_task_add_result_option (struct rspamd_task *task,
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);
@@ -571,6 +587,10 @@ rspamd_task_add_result_option (struct rspamd_task *task,
ret = TRUE;
}
+
+ if (ret && s->opts_len >= 0) {
+ s->opts_len += vlen;
+ }
}
else if (!val) {
ret = TRUE;