From: Marco Bettini Date: Mon, 16 Jan 2023 14:14:34 +0000 (+0000) Subject: lib-smtp: smtp_server_connection_input() - Ensure output errors (and closure) are... X-Git-Tag: 2.4.0~3180 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e2462ed235e1a764d032df6ff547067a8d3febd;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: smtp_server_connection_input() - Ensure output errors (and closure) are handled This is especially critical while performing the DATA command. The DATA (and AUTH) command use smtp_server_connection_reply_immediate() from within the connection input handler. Without the new code, output errors in that function are not caught and lead to the server to hang if the connection is closed in the right moment. --- diff --git a/src/lib-smtp/smtp-server-connection.c b/src/lib-smtp/smtp-server-connection.c index 20f0881160..d31305ec3e 100644 --- a/src/lib-smtp/smtp-server-connection.c +++ b/src/lib-smtp/smtp-server-connection.c @@ -600,6 +600,11 @@ static void smtp_server_connection_input(struct connection *_conn) conn->callbacks->conn_cmd_input_post != NULL) conn->callbacks->conn_cmd_input_post(conn->context); conn->handling_input = FALSE; + + /* Handle output errors from immediate replies sent to client + (normal replies are exclusively sent in output handler). */ + if (conn->conn.output != NULL && conn->conn.output->closed) + smtp_server_connection_handle_output_error(conn); smtp_server_connection_unref(&conn); }