reject bare carriage-returns in addition to the bare line-feeds

(based on a patch from Robert James Kaes, thanks!)


git-svn-id: https://svn.perl.org/qpsmtpd/trunk@209 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Ask Bjørn Hansen 2004-03-04 04:30:02 +00:00
parent 87802c4505
commit 22523ead2d
2 changed files with 17 additions and 7 deletions

View File

@ -1,5 +1,8 @@
0.27 0.27
reject bare carriage-returns in addition to the bare line-feeds
(based on a patch from Robert James Kaes, thanks!)
Bugfix to the count_unrecognized_commands plugin so it works Bugfix to the count_unrecognized_commands plugin so it works
under PPerl (it wasn't resetting the count properly). under PPerl (it wasn't resetting the count properly).

View File

@ -289,7 +289,7 @@ sub help {
my $self = shift; my $self = shift;
$self->respond(214, $self->respond(214,
"This is qpsmtpd " . $self->version, "This is qpsmtpd " . $self->version,
"See http://develooper.com/code/qpsmtpd/", "See http://smtpd.develooper.com/",
'To report bugs or send comments, mail to <ask@develooper.com>.'); 'To report bugs or send comments, mail to <ask@develooper.com>.');
} }
@ -348,16 +348,23 @@ sub data {
while (<STDIN>) { while (<STDIN>) {
$complete++, last if $_ eq ".\r\n"; $complete++, last if $_ eq ".\r\n";
$i++; $i++;
$_ eq ".\n"
and $self->respond(451, "See http://develooper.com/code/qpsmtpd/barelf.html") # should probably use \012 and \015 in these checks instead of \r and \n ...
and $self->disconnect;
# Reject messages that have either bare LF or CR. rjkaes noticed a
# lot of spam that is malformed in the header.
($_ eq ".\n" or $_ eq ".\r")
and $self->respond(421, "See http://smtpd.develooper.com/barelf.html")
and return $self->disconnect;
# add a transaction->blocked check back here when we have line by line plugin access... # add a transaction->blocked check back here when we have line by line plugin access...
unless (($max_size and $size > $max_size)) { unless (($max_size and $size > $max_size)) {
s/\r\n$/\n/; s/\r\n$/\n/;
s/^\.\./\./; s/^\.\./\./;
if ($in_header and m/^\s*$/) { if ($in_header and m/^\s*$/) {
$in_header = 0; $in_header = 0;
my @header = split /^/m, $buffer; my @headers = split /^/m, $buffer;
# ... need to check that we don't reformat any of the received lines. # ... need to check that we don't reformat any of the received lines.
# #
@ -366,8 +373,8 @@ sub data {
# gateway MUST prepend a Received: line, but it MUST NOT alter in any # gateway MUST prepend a Received: line, but it MUST NOT alter in any
# way a Received: line that is already in the header. # way a Received: line that is already in the header.
$header->extract(\@header); $header->extract(\@headers);
#$header->add("X-SMTPD", "qpsmtpd/".$self->version.", http://develooper.com/code/qpsmtpd/"); #$header->add("X-SMTPD", "qpsmtpd/".$self->version.", http://smtpd.develooper.com/");
$buffer = ""; $buffer = "";