<<< Date Index >>>     <<< Thread Index >>>

Re: mutt/2094: ESMTP patch: newline conversion and faulty error checking



The following reply was made to PR mutt/2094; it has been noted by GNATS.

From: Ralf Wildenhues <wildenhues@xxxxxxxxxxxxxxx>
To: bug-any@xxxxxxxxxxxxx
Cc: 
Subject: Re: mutt/2094: ESMTP patch: newline conversion and faulty error 
checking
Date: Tue, 27 Sep 2005 14:41:25 +0200

 * TAKAHASHI Tamotsu wrote on Tue, Sep 27, 2005 at 12:48:07PM CEST:
 > > >Number:         2094
 > > >Notify-List:    
 > > >Category:       mutt
 > > >Synopsis:       ESMTP patch: newline conversion and faulty error checking
 > 
 > > >Release:        CVS HEAD + patch-1.5.11.bc.smtp.10
 > 
 > > >Description:
 > > The ESMTP patch proposed for mutt writes out the mail
 > > header+body with plain \n instead of \r\n.  qmail does
 > > not accept it.  Snippet from strace output:
 > (snip)
 > 
 > I think Mutt-smtp currently writes exactly what fgets reads.
 > Here is an untested patch.
 
 It doesn't work, but can easily be corrected, see below.  Note that even
 with this patch, you have an issue if the \r\n does not fit in the buffer.
 
 > > After the send failure, I can edit/postpone the message,
 > > but it is also wrongly stored in Fcc.
 > 
 > Mutt saves FCC _before_ sending a message.
 > If FCC fails, mutt does not try to send it.
 
 Oh, I didn't know that, really.  Shows how many failed sends I've had.
 :)
 
 Thanks for the quick response!
 
 Cheers,
 Ralf
 
 --- orig/smtp.c        2005-09-27 14:24:32.000000000 +0200
 +++ mutt/smtp.c        2005-09-27 14:22:35.000000000 +0200
 @@ -144,6 +144,7 @@
    progress_t progress;
    struct stat st;
    int r;
 +  size_t buflen;
  
    fp = fopen (msgfile, "r");
    if (!fp)
 @@ -170,6 +171,10 @@
    
    while (fgets (buf, sizeof (buf), fp))
    {
 +    buflen = mutt_strlen (buf);
 +    if (buflen && buf[buflen-1] == '\n'
 +      && (buflen == 1 || buf[buflen - 2] != '\r'))
 +      snprintf (buf + buflen - 1, sizeof (buf) - buflen + 1, "\r\n");
      if (buf[0] == '.')
      {
        if (mutt_socket_write_d (conn, ".", 3) == -1)