They might be reused in a session if an SMTP client proceeded
unauthenticated after previous invalid authentication attempts.
This could confuse an authentication server when passing stale
credentials along with "Auth-Method: none".
The condition to send the "Auth-Salt" header is similarly refined.
b->last = ngx_copy(b->last, passwd.data, passwd.len);
*b->last++ = CR; *b->last++ = LF;
- if (s->auth_method != NGX_MAIL_AUTH_PLAIN && s->salt.len) {
+ if ((s->auth_method == NGX_MAIL_AUTH_APOP
+ || s->auth_method == NGX_MAIL_AUTH_CRAM_MD5)
+ && s->salt.len)
+ {
b->last = ngx_cpymem(b->last, "Auth-Salt: ", sizeof("Auth-Salt: ") - 1);
b->last = ngx_copy(b->last, s->salt.data, s->salt.len);
ngx_str_set(&s->out, smtp_ok);
+ ngx_str_null(&s->login);
+ ngx_str_null(&s->passwd);
+
return NGX_OK;
}