From 9c7093f674f416e766668c23c8400662d5434786 Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 11 Jun 2019 15:46:55 +0200 Subject: Add max recipients limit --- qmail-smtpd.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/qmail-smtpd.c b/qmail-smtpd.c index 38c5929..839f2d3 100644 --- a/qmail-smtpd.c +++ b/qmail-smtpd.c @@ -53,6 +53,8 @@ unsigned int mfchk = 0; unsigned int greetdelay = 0; unsigned int drop_pre_greet = 0; int timeout = 1200; +int recipcount = 0; +unsigned int max_recipcount = 100; const char *protocol = "SMTP"; @@ -312,6 +314,9 @@ void setup() x = env_get("DROP_PRE_GREET"); if (x) { scan_ulong(x, &u); drop_pre_greet = u; } + x = env_get("MAXRCPT"); + if (x) { scan_ulong(x,&u); max_recipcount = u; } + remoteip = env_get("TCPREMOTEIP"); if (!remoteip) remoteip = "unknown"; local = env_get("TCPLOCALHOST"); @@ -539,7 +544,6 @@ stralloc mailfrom = {0}; stralloc rcptto = {0}; stralloc fuser = {0}; stralloc mfparms = {0}; -int recipcount; int mailfrom_size(arg) char *arg; { @@ -731,6 +735,11 @@ void smtp_rcpt(arg) char *arg; { if (!seenmail) { err_wantmail(); return; } if (!addrparse(arg)) { err_syntax(); return; } if (!relayclient && addrrelay()) { err_relay(); return; } + if (recipcount >= max_recipcount) { + out("450 4.7.1 Error: too many recipients\r\n"); + strerr_warn2("qmail-smtpd: too many recipients at ",remoteip,0); + return; + } if (flagbarfbhelo) { if (logregex) { strerr_warn6("qmail-smtpd: badhelo: <",helohost.s,"> at ",remoteip," matches pattern: ",matchedregex.s,0); -- cgit v1.2.3