]> granicus.if.org Git - neomutt/commitdiff
Clear connection input buffer when closing
authorBeck, Andre <beck@ibh.de>
Fri, 11 Oct 2019 11:17:58 +0000 (19:17 +0800)
committerRichard Russon <rich@flatcap.org>
Fri, 11 Oct 2019 13:33:19 +0000 (14:33 +0100)
An RFC-violating reply from the Dovecot SMTP submission service
uncovered a bug in Mutt.  Mutt was not clearing out the input buffer
when closing the connection.

Dovecot was including an extra 250 response after data submission:

  DATA
  354 OK
  Subject: Test 3

  Test 3
  .
  250 2.0.0  223 byte chunk, total 223
  250 2.0.0 OK id=1iIqT1-0004wS-Ac
  quit
  221 2.0.0 Bye

The multiline 250 reply requires a hyphen in the first response.  Mutt
closes the connection after the quit, but ends up leaving the
unexpected second line in the input buffer.  This causes an error in
the next usage of the connection.

Clean out bufpos and available when closing the socket.

Co-authored-by: Richard Russon <rich@flatcap.org>
conn/socket.c

index f9830196ac67499d11b0a4b891456bef1690aea5..6520ebbc55421187a26058640f13b8fcc8ee5d46 100644 (file)
@@ -106,6 +106,8 @@ int mutt_socket_close(struct Connection *conn)
 
   conn->fd = -1;
   conn->ssf = 0;
+  conn->bufpos = 0;
+  conn->available = 0;
 
   return rc;
 }