dns_max_requests = 64;
max_lua_urls = 1024;
max_urls = 10240;
+max_recipients = 1024;
dns {
timeout = 1s;
}
struct rspamd_email_address *
-rspamd_email_address_from_smtp (const gchar *str, guint len, gint max_elements)
+rspamd_email_address_from_smtp (const gchar *str, guint len)
{
struct rspamd_email_address addr, *ret;
gsize nlen;
* @param len length of string
* @return
*/
-struct rspamd_email_address *rspamd_email_address_from_smtp (const gchar *str,
- guint len,
- gint max_elements);
+struct rspamd_email_address *rspamd_email_address_from_smtp (const gchar *str, guint len);
/**
* Parses email address from the mime header, decodes names and return the array
#include "contrib/uthash/utlist.h"
#include "libserver/mempool_vars_internal.h"
#include "libserver/url.h"
+#include "libserver/cfg_file.h"
#include "libutil/util.h"
#include <unicode/utf8.h>
case 0x76F31A09F4352521ULL: /* to */
MESSAGE_FIELD (task, rcpt_mime) = rspamd_email_address_from_mime (task->task_pool,
rh->decoded, strlen (rh->decoded),
- MESSAGE_FIELD (task, rcpt_mime), -1);
+ MESSAGE_FIELD (task, rcpt_mime), task->cfg->max_recipients);
rh->flags |= RSPAMD_HEADER_TO|RSPAMD_HEADER_RCPT|RSPAMD_HEADER_UNIQUE;
break;
case 0x7EB117C1480B76ULL: /* cc */
MESSAGE_FIELD (task, rcpt_mime) = rspamd_email_address_from_mime (task->task_pool,
rh->decoded, strlen (rh->decoded),
- MESSAGE_FIELD (task, rcpt_mime), -1);
+ MESSAGE_FIELD (task, rcpt_mime), task->cfg->max_recipients);
rh->flags |= RSPAMD_HEADER_CC|RSPAMD_HEADER_RCPT|RSPAMD_HEADER_UNIQUE;
break;
case 0xE4923E11C4989C8DULL: /* bcc */
MESSAGE_FIELD (task, rcpt_mime) = rspamd_email_address_from_mime (task->task_pool,
rh->decoded, strlen (rh->decoded),
- MESSAGE_FIELD (task, rcpt_mime), -1);
+ MESSAGE_FIELD (task, rcpt_mime), task->cfg->max_recipients);
rh->flags |= RSPAMD_HEADER_BCC|RSPAMD_HEADER_RCPT|RSPAMD_HEADER_UNIQUE;
break;
case 0x41E1985EDC1CBDE4ULL: /* from */
MESSAGE_FIELD (task, from_mime) = rspamd_email_address_from_mime (task->task_pool,
rh->decoded, strlen (rh->decoded),
- MESSAGE_FIELD (task, from_mime), -1);
+ MESSAGE_FIELD (task, from_mime), task->cfg->max_recipients);
rh->flags |= RSPAMD_HEADER_FROM|RSPAMD_HEADER_SENDER|RSPAMD_HEADER_UNIQUE;
break;
case 0x43A558FC7C240226ULL: /* message-id */ {
case 0xEE4AA2EAAC61D6F4ULL: /* return-path */
if (task->from_envelope == NULL) {
task->from_envelope = rspamd_email_address_from_smtp (rh->decoded,
- strlen (rh->decoded), -1);
+ strlen (rh->decoded));
}
rh->flags = RSPAMD_HEADER_RETURN_PATH|RSPAMD_HEADER_UNIQUE;
break;
guint full_gc_iters; /**< iterations between full gc cycle */
guint max_lua_urls; /**< maximum number of urls to be passed to Lua */
guint max_urls; /**< maximum number of urls to be processed in general */
+ gint max_recipients; /**< maximum number of recipients to be processed */
guint max_blas_threads; /**< maximum threads for openblas when learning ANN */
guint max_opts_len; /**< maximum length for all options for a symbol */
G_STRUCT_OFFSET (struct rspamd_config, max_urls),
RSPAMD_CL_FLAG_INT_32,
"Maximum count of URLs to process to avoid DoS (default: 10240)");
+ rspamd_rcl_add_default_handler (sub,
+ "max_recipients",
+ rspamd_rcl_parse_struct_integer,
+ G_STRUCT_OFFSET (struct rspamd_config, max_recipients),
+ RSPAMD_CL_FLAG_INT_32,
+ "Maximum count of recipients to process to avoid DoS (default: 1024)");
rspamd_rcl_add_default_handler (sub,
"max_blas_threads",
rspamd_rcl_parse_struct_integer,
cfg->cache_reload_time = 30.0;
cfg->max_lua_urls = 1024;
cfg->max_urls = cfg->max_lua_urls * 10;
+ cfg->max_recipients = 1024;
cfg->max_blas_threads = 1;
cfg->max_opts_len = 4096;
cpy = rspamd_mempool_alloc (priv->pool, zero - pos);
memcpy (cpy, pos, zero - pos);
msg_debug_milter ("got mail: %*s", (int)(zero - pos), cpy);
- addr = rspamd_email_address_from_smtp (cpy, zero - pos, -1);
+ addr = rspamd_email_address_from_smtp (cpy, zero - pos);
if (addr) {
session->from = addr;
/* That actually should not happen */
cpy = rspamd_mempool_alloc (priv->pool, end - pos);
memcpy (cpy, pos, end - pos);
- addr = rspamd_email_address_from_smtp (cpy, end - pos, -1);
+ addr = rspamd_email_address_from_smtp (cpy, end - pos);
if (addr) {
session->from = addr;
memcpy (cpy, pos, end - pos);
msg_debug_milter ("got rcpt: %*s", (int)(zero - pos), cpy);
- addr = rspamd_email_address_from_smtp (cpy, zero - pos, -1);
+ addr = rspamd_email_address_from_smtp (cpy, zero - pos);
if (addr) {
if (!session->rcpts) {
msg_debug_milter ("got weird rcpt: %*s", (int)(end - pos),
pos);
/* That actually should not happen */
- addr = rspamd_email_address_from_smtp (cpy, end - pos, -1);
+ addr = rspamd_email_address_from_smtp (cpy, end - pos);
if (addr) {
if (!session->rcpts) {
else if (*p == ',' && start_addr != NULL && p > start_addr) {
/* We have finished address, check what we have */
addr = rspamd_email_address_from_smtp (start_addr,
- p - start_addr, -1);
+ p - start_addr);
if (addr) {
if (task->rcpt_envelope == NULL) {
if (start_addr && p > start_addr) {
switch (state) {
case normal_string:
- addr = rspamd_email_address_from_smtp (start_addr, end - start_addr, -1);
+ addr = rspamd_email_address_from_smtp (start_addr, end - start_addr);
if (addr) {
if (task->rcpt_envelope == NULL) {
IF_HEADER (FROM_HEADER) {
task->from_envelope = rspamd_email_address_from_smtp (
hv_tok->begin,
- hv_tok->len, -1);
+ hv_tok->len);
msg_debug_protocol ("read from header, value: %T", hv_tok);
if (!task->from_envelope) {