Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend barelf check to whole message #318

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/Qpsmtpd/SMTP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -681,21 +681,21 @@ sub data_respond {

my $timeout = $self->config('timeout');
while (defined($_ = $self->getline($timeout))) {
if ($_ eq ".\r\n") {
$complete++;
$_ = '';
}
$i++;

# Reject messages that have either bare LF or CR. rjkaes noticed a
# lot of spam that is malformed in the header.

if ($_ eq ".\n" || $_ eq ".\r") {
if ($_ !~ /\r\n$/) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, why isn't \n$ allowed inside the message body? It wouldn't be a new line, technically, just a \n inside a message.

I thought it should only be disallowed as a "end of message" marker.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RFC 5322 (2008), Section 4: "Finally, certain characters that were formerly allowed in messages appear in this section.... CR and LF were allowed to appear in messages other than as CRLF;"

Appendix B.27: "Free CR and LF not allowed."

$self->respond(421, 'See http://smtpd.develooper.com/barelf.html');
$self->disconnect;
return 1;
}

if ($_ eq ".\r\n") {
$complete++;
$_ = '';
}
$i++;

unless (($max_size and $size > $max_size)) {
s/\r\n$/\n/;
s/^\.\./\./;
Expand Down