Skip to content

Commit

Permalink
lib-smtp: server: STARTTLS command: Properly handle output stream flu…
Browse files Browse the repository at this point in the history
…sh error.
  • Loading branch information
stephanbosch committed Feb 17, 2018
1 parent 1e3de39 commit 95a139b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib-smtp/smtp-server-cmd-starttls.c
Expand Up @@ -70,6 +70,7 @@ static void cmd_starttls_destroy(struct smtp_server_cmd_ctx *cmd)
{
struct smtp_server_connection *conn = cmd->conn;
struct smtp_server_command *command = cmd->cmd;
int ret;

if (conn->conn.output == NULL)
return;
Expand All @@ -81,8 +82,12 @@ static void cmd_starttls_destroy(struct smtp_server_cmd_ctx *cmd)
/* uncork */
o_stream_uncork(conn->conn.output);

if (o_stream_flush(conn->conn.output) <= 0) {
/* flush */
if ((ret=smtp_server_connection_flush(conn)) < 0) {
return;
} else if (ret == 0) {
/* the buffer has to be flushed */
i_assert(!conn->conn.output->closed);
o_stream_set_flush_callback(conn->conn.output,
cmd_starttls_output,
conn);
Expand Down

0 comments on commit 95a139b

Please sign in to comment.