From: Beck, Andre Date: Fri, 11 Oct 2019 11:17:58 +0000 (+0800) Subject: Clear connection input buffer when closing. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=937a1eb12570f5daf598359fa490ccfde1ca0daf;p=mutt Clear connection input buffer when closing. 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. --- diff --git a/mutt_socket.c b/mutt_socket.c index 9c22f35f..44842cc4 100644 --- a/mutt_socket.c +++ b/mutt_socket.c @@ -84,6 +84,8 @@ int mutt_socket_close (CONNECTION* conn) conn->fd = -1; conn->ssf = 0; + conn->bufpos = 0; + conn->available = 0; return rc; }