[nginx] Mail: handling of read buffer filled with commands.
Maxim Dounin
mdounin at mdounin.ru
Sat Mar 30 04:59:45 UTC 2024
details: http://freenginx.org/hg/nginx/rev/c690a902bfec
branches:
changeset: 9234:c690a902bfec
user: Maxim Dounin <mdounin at mdounin.ru>
date: Sat Mar 30 05:05:05 2024 +0300
description:
Mail: handling of read buffer filled with commands.
If the whole read buffer was filled with commands during authentication,
exactly matching the buffer boundary, this did not cause the "client sent
too long command" error, but might result in read events being disabled
for the connection, notably with level-triggered event methods, leading
to a connection hang.
Fix is to ensure that s->blocked is set in case of c->read->ready, so
command reading is resumed after sending responses to previous commands.
diffstat:
src/mail/ngx_mail_imap_handler.c | 2 +-
src/mail/ngx_mail_pop3_handler.c | 2 +-
src/mail/ngx_mail_smtp_handler.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diffs (36 lines):
diff --git a/src/mail/ngx_mail_imap_handler.c b/src/mail/ngx_mail_imap_handler.c
--- a/src/mail/ngx_mail_imap_handler.c
+++ b/src/mail/ngx_mail_imap_handler.c
@@ -226,7 +226,7 @@ ngx_mail_imap_auth_state(ngx_event_t *re
ngx_str_set(&s->out, imap_next);
}
- if (s->buffer->pos < s->buffer->last) {
+ if (s->buffer->pos < s->buffer->last || c->read->ready) {
s->blocked = 1;
}
diff --git a/src/mail/ngx_mail_pop3_handler.c b/src/mail/ngx_mail_pop3_handler.c
--- a/src/mail/ngx_mail_pop3_handler.c
+++ b/src/mail/ngx_mail_pop3_handler.c
@@ -262,7 +262,7 @@ ngx_mail_pop3_auth_state(ngx_event_t *re
}
}
- if (s->buffer->pos < s->buffer->last) {
+ if (s->buffer->pos < s->buffer->last || c->read->ready) {
s->blocked = 1;
}
diff --git a/src/mail/ngx_mail_smtp_handler.c b/src/mail/ngx_mail_smtp_handler.c
--- a/src/mail/ngx_mail_smtp_handler.c
+++ b/src/mail/ngx_mail_smtp_handler.c
@@ -550,7 +550,7 @@ ngx_mail_smtp_auth_state(ngx_event_t *re
}
}
- if (s->buffer->pos < s->buffer->last) {
+ if (s->buffer->pos < s->buffer->last || c->read->ready) {
s->blocked = 1;
}
More information about the nginx-devel
mailing list