[PATCH 19 of 31] Mail: handle smtp multiline replies
Maxim Dounin
mdounin at mdounin.ru
Mon Jun 27 21:06:49 MSD 2011
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1309187091 -14400
# Node ID cff690c009b20cf8b0b5d0fcad7e7fbe6bc0b3a0
# Parent e56caa64771c6fcffa661943b8b3e4f2a291d485
Mail: handle smtp multiline replies.
See here for details:
http://nginx.org/pipermail/nginx/2010-August/021713.html
http://nginx.org/pipermail/nginx/2010-August/021784.html
http://nginx.org/pipermail/nginx/2010-August/021785.html
diff --git a/src/mail/ngx_mail_proxy_module.c b/src/mail/ngx_mail_proxy_module.c
--- a/src/mail/ngx_mail_proxy_module.c
+++ b/src/mail/ngx_mail_proxy_module.c
@@ -701,7 +701,7 @@ ngx_mail_proxy_dummy_handler(ngx_event_t
static ngx_int_t
ngx_mail_proxy_read_response(ngx_mail_session_t *s, ngx_uint_t state)
{
- u_char *p;
+ u_char *p, *m;
ssize_t n;
ngx_buf_t *b;
ngx_mail_proxy_conf_t *pcf;
@@ -778,6 +778,25 @@ ngx_mail_proxy_read_response(ngx_mail_se
break;
default: /* NGX_MAIL_SMTP_PROTOCOL */
+
+ if (p[3] == '-') {
+ /* multiline reply, check if we got last line */
+
+ m = b->last - (sizeof(CRLF "200" CRLF) - 1);
+
+ while (m > p) {
+ if (m[0] == CR && m[1] == LF) {
+ break;
+ }
+
+ m--;
+ }
+
+ if (m <= p || m[5] == '-') {
+ return NGX_AGAIN;
+ }
+ }
+
switch (state) {
case ngx_smtp_start:
More information about the nginx-devel
mailing list