I noticed this evening that if an smtp connect fails while in the DATA
section of the conversation, qpsmptd will attempt to deliver a
fragmentary message (if no data had yet been received, it will write an
undef to qmail-queue).

Here's a fix.  It'll probably be offset a little from stock qpsmtpd.


--- /tmp/qpsmtpd.orig   Wed Apr  3 22:15:58 2002
+++ /usr/sbin/qpsmtpd   Wed Apr  3 22:22:26 2002
@@ -195,14 +195,16 @@
   respond(503, "MAIL first"), return 1 unless $state{transaction}->{from};
   respond(503, "RCPT first"), return 1 unless $state{transaction}->{rcpt};
   respond(354, "go ahead");
-  my $buffer;
+  my $buffer = '';
   my $size = 0;
   my $i = 0;
   my $max_size = get_config('databytes') || 0;
   my $blocked = "";
   my $header = 1;
+  my $complete = 0;
+  
   while (<STDIN>) {
-    last if $_ eq ".\r\n";
+    $complete++, last if $_ eq ".\r\n";
     $i++;
     respond(451, "See http://develooper.com/code/qpsmtpd/barelf.html";), exit
       if $_ eq ".\n";
@@ -220,6 +222,10 @@
 
     alarm $config{timeout};
   }
+
+  # if we get here without seeing a terminator, the connection is
+  # probably dead.
+  respond(451, "Incomplete DATA"), return 1 unless $complete;
 
   respond(550, $blocked),return 1 if $blocked;
   respond(552, "Message too big!"),return 1 if $max_size and $size > $max_size;

-- 
Devin  \ aqua(at)devin.com, 1024D/E9ABFCD2;  http://www.devin.com
Carraway \ IRC: Requiem  GCS/CC/L s-:--- !a !tv C++++$ ULB+++$ O+@ P L+++

Reply via email to