When a client command starts an auth_http request, the default reply
set by the POP3, IMAP and SMTP auth state handlers remains in s->out,
though it is never used: the actual reply depends on the auth_http
response. With ngx_mail_send() as the client write handler, the reply
could be sent before the authentication result was known, and if the
client reset the connection, the failed send destroyed the session
while the auth_http connection still referenced it.
The queued reply is now discarded when the auth_http request starts,
similarly to ngx_mail_proxy_init().
Reported by Xint.io.
ctx->peer.connection->data = s;
ctx->peer.connection->pool = s->connection->pool;
+ s->out.len = 0;
+
s->connection->read->handler = ngx_mail_auth_http_block_read;
ctx->peer.connection->read->handler = ngx_mail_auth_http_read_handler;
ctx->peer.connection->write->handler = ngx_mail_auth_http_write_handler;