From 1e2462ed235e1a764d032df6ff547067a8d3febd Mon Sep 17 00:00:00 2001 From: Marco Bettini Date: Mon, 16 Jan 2023 14:14:34 +0000 Subject: [PATCH] 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. --- src/lib-smtp/smtp-server-connection.c | 5 +++++ 1 file changed, 5 insertions(+) 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); } -- 2.47.3