From 0664a76dc3f78a9a922ce1dcc34618e2c694eb91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ask=20Bj=C3=B8rn=20Hansen?= Date: Tue, 30 Oct 2001 12:49:47 +0000 Subject: [PATCH] test sircam block. (should be moved to external "filter") fix bug with malformed rcpt to: commands. git-svn-id: https://svn.perl.org/qpsmtpd/trunk@3 958fd67b-6ff1-0310-b445-bb7760255be9 --- qpsmtpd | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qpsmtpd b/qpsmtpd index a58ce19..891e4c2 100755 --- a/qpsmtpd +++ b/qpsmtpd @@ -146,6 +146,7 @@ sub rcpt { return respond(501, "syntax error in parameters") unless $_[0] =~ m/^to:/i; return(503, "Use MAIL before RCPT") unless $state{transaction}->{from}; my ($rcpt) = ($_[0] =~ m/to:(.*)/i)[0]; + $rcpt = $_[1] unless $rcpt; $rcpt = (Mail::Address->parse($rcpt))[0]; return respond(501, "could not parse recipient") unless $rcpt; return respond(550, "will not relay for ". $rcpt->host) unless check_relay($rcpt->host); @@ -161,6 +162,8 @@ sub data { my $size = 0; my $i = 0; my $max_size = get_config('databytes') || 0; + my $blocked = ""; + my $header = 1; while () { last if $_ eq ".\r\n"; $i++; @@ -168,6 +171,11 @@ sub data { if $_ eq ".\n"; unless ($max_size and $size > $max_size) { s/\r\n$/\n/; + $header = 0 if $header and m/^\s*$/; + $blocked = "Your mail looks too much like that SirCam nonsense, please go away" + if $header + and $state{transaction}->{from}->format eq "<>" + and $_ eq "Content-Disposition: Multipart message"; $buffer .= $_; $size += length $_; } @@ -176,6 +184,7 @@ sub data { alarm $config{timeout}; } + respond(550, $blocked),return 1 if $blocked; respond(552, "Message too big!"),return 1 if $max_size and $size > $max_size; # these bits inspired by Peter Samuels "qmail-queue wrapper"