mirror of
https://github.com/nginx/nginx.git
synced 2024-12-25 16:31:17 -06:00
Mail: fixed reading with fully filled buffer (ticket #2159).
With SMTP pipelining, ngx_mail_read_command() can be called with s->buffer without any space available, to parse additional commands received to the buffer on previous calls. Previously, this resulted in recv() being called with zero length, resulting in zero being returned, which was interpreted as a connection close by the client, so nginx silently closed connection. Fix is to avoid calling c->recv() if there is no free space in the buffer, but continue parsing of the already received commands.
This commit is contained in:
parent
ead9ab0925
commit
7b9920aad8
@ -833,6 +833,8 @@ ngx_mail_read_command(ngx_mail_session_t *s, ngx_connection_t *c)
|
|||||||
ngx_str_t l;
|
ngx_str_t l;
|
||||||
ngx_mail_core_srv_conf_t *cscf;
|
ngx_mail_core_srv_conf_t *cscf;
|
||||||
|
|
||||||
|
if (s->buffer->last < s->buffer->end) {
|
||||||
|
|
||||||
n = c->recv(c, s->buffer->last, s->buffer->end - s->buffer->last);
|
n = c->recv(c, s->buffer->last, s->buffer->end - s->buffer->last);
|
||||||
|
|
||||||
if (n == NGX_ERROR || n == 0) {
|
if (n == NGX_ERROR || n == 0) {
|
||||||
@ -849,6 +851,7 @@ ngx_mail_read_command(ngx_mail_session_t *s, ngx_connection_t *c)
|
|||||||
return NGX_AGAIN;
|
return NGX_AGAIN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module);
|
cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user