From b4d6d654e95c9ad5a019a58e69679e8dd3201dc4 Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 5 Feb 2013 18:20:18 +0100 Subject: [PATCH] Only allow one envelope recipient for bounces Refuse messages from the null envelope sender if they have more than one envelope recipient nullenvsender-recipcount --- qmail-smtpd.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qmail-smtpd.c b/qmail-smtpd.c index c8ee61b..25f821c 100644 --- a/qmail-smtpd.c +++ b/qmail-smtpd.c @@ -133,6 +133,7 @@ void err_nogateway() out(" (#5.7.1)\r\n"); } #endif +void err_badbounce() { out("550 sorry, bounce messages should have a single envelope recipient (#5.7.1)\r\n"); } void err_unimpl() { out("502 unimplemented (#5.5.1)\r\n"); } void err_syntax() { out("555 syntax error (#5.5.4)\r\n"); } void err_relay() { out("553 we don't relay (#5.7.1)\r\n"); } @@ -443,6 +444,7 @@ stralloc mailfrom = {0}; stralloc rcptto = {0}; stralloc fuser = {0}; stralloc mfparms = {0}; +int recipcount; int mailfrom_size(arg) char *arg; { @@ -559,6 +561,7 @@ void smtp_mail(arg) char *arg; if (!stralloc_copys(&rcptto,"")) die_nomem(); if (!stralloc_copys(&mailfrom,addr.s)) die_nomem(); if (!stralloc_0(&mailfrom)) die_nomem(); + recipcount = 0; out("250 ok\r\n"); } void smtp_rcpt(arg) char *arg; { @@ -610,6 +613,7 @@ void smtp_rcpt(arg) char *arg; { if (!stralloc_cats(&rcptto,"T")) die_nomem(); if (!stralloc_cats(&rcptto,addr.s)) die_nomem(); if (!stralloc_0(&rcptto)) die_nomem(); + recipcount++; out("250 ok\r\n"); } @@ -726,6 +730,7 @@ void smtp_data() { if (!seenmail) { err_wantmail(); return; } if (!rcptto.len) { err_wantrcpt(); return; } + if (mailfrom.len == 1 && recipcount > 1) { err_badbounce(); return; } if (flagbrt) { err_brt(); return; } seenmail = 0; if (databytes) bytestooverflow = databytes + 1; -- cgit v1.2.3