aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mail/ngx_mail_handler.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/mail/ngx_mail_handler.c b/src/mail/ngx_mail_handler.c
index 0aaa0e786..57503e9a6 100644
--- a/src/mail/ngx_mail_handler.c
+++ b/src/mail/ngx_mail_handler.c
@@ -833,20 +833,23 @@ ngx_mail_read_command(ngx_mail_session_t *s, ngx_connection_t *c)
ngx_str_t l;
ngx_mail_core_srv_conf_t *cscf;
- n = c->recv(c, s->buffer->last, s->buffer->end - s->buffer->last);
+ if (s->buffer->last < s->buffer->end) {
- if (n == NGX_ERROR || n == 0) {
- ngx_mail_close_connection(c);
- return NGX_ERROR;
- }
+ n = c->recv(c, s->buffer->last, s->buffer->end - s->buffer->last);
- if (n > 0) {
- s->buffer->last += n;
- }
+ if (n == NGX_ERROR || n == 0) {
+ ngx_mail_close_connection(c);
+ return NGX_ERROR;
+ }
- if (n == NGX_AGAIN) {
- if (s->buffer->pos == s->buffer->last) {
- return NGX_AGAIN;
+ if (n > 0) {
+ s->buffer->last += n;
+ }
+
+ if (n == NGX_AGAIN) {
+ if (s->buffer->pos == s->buffer->last) {
+ return NGX_AGAIN;
+ }
}
}