summaryrefslogtreecommitdiffhomepage
path: root/src/mail
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2021-05-19 03:13:15 +0300
committerMaxim Dounin <mdounin@mdounin.ru>2021-05-19 03:13:15 +0300
commit204f944add09c43223de317451175d5fdb7d1fb0 (patch)
treea44aa50c82c58cf7cf90084e7e32b982be521411 /src/mail
parent60a5a6f0d37b2e10d8d4aab97b64f4048e99c99a (diff)
downloadnginx-204f944add09c43223de317451175d5fdb7d1fb0.tar.gz
nginx-204f944add09c43223de317451175d5fdb7d1fb0.tar.bz2
Mail: fixed handling of invalid SMTP commands split between reads.
Previously, if an invalid SMTP command was split between reads, nginx failed to wait for LF before returning an error, and interpreted the rest of the command received later as a separate command. The sw_invalid state in ngx_mail_smtp_parse_command(), introduced in 04e43d03e153, did not work, since ngx_mail_smtp_auth_state() clears s->state when returning an error due to NGX_MAIL_PARSE_INVALID_COMMAND. And not clearing s->state will introduce another problem: the rest of the command would trigger duplicate error when rest of the command is received. Fix is to return NGX_AGAIN from ngx_mail_smtp_parse_command() until full command is received.
Diffstat (limited to 'src/mail')
-rw-r--r--src/mail/ngx_mail_parse.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/mail/ngx_mail_parse.c b/src/mail/ngx_mail_parse.c
index 2c2cdffa1..0712ad5dc 100644
--- a/src/mail/ngx_mail_parse.c
+++ b/src/mail/ngx_mail_parse.c
@@ -846,14 +846,14 @@ invalid:
for (p = s->buffer->pos; p < s->buffer->last; p++) {
if (*p == LF) {
s->state = sw_start;
- p++;
- break;
+ s->buffer->pos = p + 1;
+ return NGX_MAIL_PARSE_INVALID_COMMAND;
}
}
s->buffer->pos = p;
- return NGX_MAIL_PARSE_INVALID_COMMAND;
+ return NGX_AGAIN;
}