Skip Menu |

This queue is for tickets about the Net-Server-Mail CPAN distribution.

Report information
The Basics
Id: 24038
Status: resolved
Priority: 0/
Queue: Net-Server-Mail

People
Owner: x.guimard [...] free.fr
Requestors: x.guimard [...] free.fr
ludo.bretel [...] francetelecom.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.13
Fixed in: 0.14



Subject: Broken pipe when a data_part begin '.CRLF' and is not data_end
Hello, There is a bug in Server::Mail::SMTP.pm When a mail DATA is cut in 2 data_part exactly at the end of a line! The second data_part begin with '.CRLF' and is consider by sub data_part as data_end which is an error ! Example of mail with > 4096 characters : .... il fait beau vivre en France.CRLF .... is cut in 2 data_part : First data_part (4096 characters with Postfix) : .... il fait beau vivre en France Second data_part (<= 4096 characters): .CRLF .... function Server::Mail::SMTP::data_part "if($data =~ /^\.\r?\n/m)" consider that second part begin as DATA end ! And in result $self->{_data} there is only first data_part ! In RFC2821 DATA end is 'CRLF.CRLF' and not only '^.CRLF' ! In section : 4.1.1.4 DATA (DATA) The mail data is terminated by a line containing only a period, that is, the character sequence "<CRLF>.<CRLF>" (see section 4.5.2). My environment : - LINUX RHEL 3.0 - Perl 5.8.0 - Net-Server-Mail 0.13 Can you help me to correct this bug Thanks for your help
Subject: Bug in end-of-mail detection
Date: Thu, 21 Dec 2006 18:05:05 +0100
To: bug-Net-Server-Mail [...] rt.cpan.org
From: Xavier <x.guimard [...] free.fr>
Hello, when a mail has 4095 bytes, the \r\n.\r\n is cutted in two call of &data_part and the detection does not work. When a line is finished by a "." but cutted just before (each chunk is 4096 long), the module reports a 453 error. Below a proposed patch: --- /usr/share/perl5/Net/Server/Mail/SMTP.pm 2006-12-21 17:45:41.435756848 +0100 +++ /root/new/SMTP.pm 2006-12-21 17:45:09.360633008 +0100 @@ -556,6 +556,7 @@ return; } + $self->{_last_chunk} = ''; $self->make_event ( name => 'DATA-INIT', @@ -571,7 +572,7 @@ my($self, $data) = @_; # search for end of data indicator - if($data =~ /^\.\r?\n/m) + if("$self->{last_chunk}.$data" =~ /^\.\r*\n/m) { if(length $') { @@ -603,6 +604,7 @@ success_reply => '', # don't send any reply ! ); + $self->{last_chunk} = substr $data, -2; return; }
Subject: [rt.cpan.org #24038] Correction in proposed patch
Date: Fri, 22 Dec 2006 10:52:02 +0100
To: bug-Net-Server-Mail [...] rt.cpan.org
From: Xavier <x.guimard [...] free.fr>
This patch correct error when \r\n.\r\n is cutted in two pieces. Yesterday, I've done a mistake. Below an other proposed patch: --- SMTP.pm 2005-09-01 11:10:18.000000000 +0200 +++ SMTP-new.pm 2006-12-22 10:48:40.602705152 +0100 @@ -560,6 +560,7 @@ return; } + $self->{_last_chunk} = ''; $self->make_event ( name => 'DATA-INIT', @@ -575,7 +576,7 @@ my($self, $data) = @_; # search for end of data indicator - if($data =~ /^\.\r?\n/m) + if("$self->{last_chunk}$data" =~ /^\.\r*\n/m) { my $more_data = $'; if(length $more_data) @@ -610,6 +611,7 @@ success_reply => '', # don't send any reply ! ); + $self->{last_chunk} = substr $data, -2; return; }
CC: rs-pause [...] rhapsodyk.net
Subject: [rt.cpan.org #24038] New proposed patch
Date: Fri, 29 Dec 2006 17:51:30 +0100
To: bug-Net-Server-Mail [...] rt.cpan.org
From: Xavier <x.guimard [...] free.fr>
Hello, Since I'm using Net::Server::Mail::SMTP on a server subjected to a very strong load, I've found an other problem: with my precedent patch, if $last_chunk contains a string starting with '.', &data detects a end of mail. Below a new proposed patch: --- Net-Server-Mail-0.13/lib/Net/Server/Mail/SMTP.pm 2005-09-01 11:10:18.000000000 +0200 +++ SMTP.pm 2006-12-29 17:37:01.000000000 +0100 @@ -560,6 +560,7 @@ return; } + $self->{_last_chunk} = ''; $self->make_event ( name => 'DATA-INIT', @@ -575,7 +576,7 @@ my($self, $data) = @_; # search for end of data indicator - if($data =~ /^\.\r?\n/m) + if("$self->{last_chunk}$data" =~ /^\.\r*\n/m ) { my $more_data = $'; if(length $more_data) @@ -583,6 +584,7 @@ # Client sent a command after the end of data indicator ".". if(!$self->{data_handle_more_data}) { + print STDERR "DONNEES PARASITES #$self->{last_chunk}#$more_data"; $self->reply(453, "Command received prior to completion of". " previous command sequence"); return; @@ -590,13 +592,14 @@ } # RFC 821 compliance. - ($data = $`) =~ s/^\.//mg; + #($data = $`) =~ s/^\.//mg; + $data =~ s/^\.\r*\n$//m; $self->{_data} .= $data; return $self->data_finished($more_data); } # RFC 821 compliance. - $data =~ s/^\.//mg; + #$data =~ s/^\.//mg; $self->make_event ( name => 'DATA-PART', @@ -610,6 +613,7 @@ success_reply => '', # don't send any reply ! ); + $self->{last_chunk} = '_'.substr $data, -5; return; }
Subject: Cleaned patch
Date: Mon, 08 Jan 2007 21:38:55 +0100
To: bug-Net-Server-Mail [...] rt.cpan.org
From: Xavier Guimard <x.guimard [...] free.fr>
Hello, I've cleaned my proposed patch. Thanks, Xavier
diff -aburN libnet-server-mail-perl-0.13/lib/Net/Server/Mail/SMTP.pm libnet-server-mail-perl-0.13-1/lib/Net/Server/Mail/SMTP.pm --- libnet-server-mail-perl-0.13/lib/Net/Server/Mail/SMTP.pm 2005-09-01 11:10:18.000000000 +0200 +++ libnet-server-mail-perl-0.13-1/lib/Net/Server/Mail/SMTP.pm 2007-01-08 21:33:27.000000000 +0100 @@ -560,6 +560,7 @@ return; } + $self->{_last_chunk} = ''; $self->make_event ( name => 'DATA-INIT', @@ -575,7 +576,7 @@ my($self, $data) = @_; # search for end of data indicator - if($data =~ /^\.\r?\n/m) + if("$self->{last_chunk}$data" =~ /^\.\r*\n/m ) { my $more_data = $'; if(length $more_data) @@ -590,13 +591,13 @@ } # RFC 821 compliance. - ($data = $`) =~ s/^\.//mg; + $data =~ s/^\.\r*\n$//m; $self->{_data} .= $data; return $self->data_finished($more_data); } # RFC 821 compliance. - $data =~ s/^\.//mg; + $data =~ s/^\.\r*\n$//m; $self->make_event ( name => 'DATA-PART', @@ -610,6 +611,7 @@ success_reply => '', # don't send any reply ! ); + $self->{last_chunk} = '_'.substr $data, -5; return; }
Integrated at revision 0.14
Fixed at revision 0.14