From: Vsevolod Stakhov Date: Tue, 9 Aug 2016 13:24:52 +0000 (+0100) Subject: [Feature] Add some sanity check for very long from/to log elements X-Git-Tag: 1.3.3~43 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a0a11fb9957834effc3da06bf4f22f690e8df573;p=rspamd.git [Feature] Add some sanity check for very long from/to log elements --- diff --git a/src/libserver/task.c b/src/libserver/task.c index 95e435b6e..47e9aa1c5 100644 --- a/src/libserver/task.c +++ b/src/libserver/task.c @@ -1025,7 +1025,7 @@ rspamd_task_write_ialist (struct rspamd_task *task, rspamd_ftok_t var = {.begin = NULL, .len = 0}; InternetAddressMailbox *iamb; InternetAddress *ia = NULL; - gint i; + gint i, nchars = 0, cur_chars; if (lim <= 0) { lim = internet_address_list_length (ialist); @@ -1039,8 +1039,10 @@ rspamd_task_write_ialist (struct rspamd_task *task, if (ia && INTERNET_ADDRESS_IS_MAILBOX (ia)) { iamb = INTERNET_ADDRESS_MAILBOX (ia); + cur_chars = strlen (iamb->addr); varbuf = rspamd_fstring_append (varbuf, iamb->addr, - strlen (iamb->addr)); + cur_chars); + nchars += cur_chars; } if (varbuf->len > 0) { @@ -1049,7 +1051,7 @@ rspamd_task_write_ialist (struct rspamd_task *task, } } - if (i >= max_log_elts) { + if (i >= max_log_elts || nchars >= max_log_elts * 10) { varbuf = rspamd_fstring_append (varbuf, "...", 3); break; }