]> git.kaiwu.me - nginx.git/commitdiff
Mail: added a check for the number of arguments in MAIL/RCPT.
authorMaxim Dounin <mdounin@mdounin.ru>
Wed, 21 May 2014 17:56:20 +0000 (21:56 +0400)
committerMaxim Dounin <mdounin@mdounin.ru>
Wed, 21 May 2014 17:56:20 +0000 (21:56 +0400)
Missed during introduction of the SMTP pipelining support (04e43d03e153,
1.5.6).  Previously, the check wasn't needed as s->buffer was used directly
and the number of arguments didn't matter.

Reported by Svyatoslav Nikolsky.

src/mail/ngx_mail_smtp_handler.c

index 52fe475234ad9f8624f1247107ab0d7f52fe841b..665f5ef193a0ecad542189e82c0a065c8eddb17d 100644 (file)
@@ -679,6 +679,11 @@ ngx_mail_smtp_mail(ngx_mail_session_t *s, ngx_connection_t *c)
         return NGX_OK;
     }
 
+    if (s->args.nelts == 0) {
+        ngx_str_set(&s->out, smtp_invalid_argument);
+        return NGX_OK;
+    }
+
     arg = s->args.elts;
     arg += s->args.nelts - 1;
 
@@ -713,6 +718,11 @@ ngx_mail_smtp_rcpt(ngx_mail_session_t *s, ngx_connection_t *c)
         return NGX_OK;
     }
 
+    if (s->args.nelts == 0) {
+        ngx_str_set(&s->out, smtp_invalid_argument);
+        return NGX_OK;
+    }
+
     arg = s->args.elts;
     arg += s->args.nelts - 1;