[nginx] Reset imap tag to empty after authentication attempt

Maxim Dounin mdounin at mdounin.ru
Wed May 15 07:37:59 UTC 2024


Hello!

On Mon, May 13, 2024 at 03:43:18PM +1000, Robert Mueller wrote:

> # HG changeset patch
> # User Rob Mueller <robm at fastmailteam.com>
> Reset imap tag to empty after authentication attempt
> 
> We need to reset the imap tag to empty after an authentication attempt
> completes, otherwise if the next line parsed is incomplete with no tag
> (e.g. empty line) then we use the "tag" from the previous buffer which
> is now definitely wrong and has been partially overwritten with the most
> recently read data (e.g. CRLF).
> 
> An example before this patch:
> 
> S: * OK IMAP4 ready
> C: foobar login a b
> S: foobar NO Incorrect username or password.
> C:
> S:
> S: obar BAD invalid command
> 
> Then with this patch:
> 
> S: * OK IMAP4 ready
> C: foobar login a b
> S: foobar NO Incorrect username or password.
> C:
> S: * BAD invalid command
> ---
>  src/mail/ngx_mail_auth_http_module.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/mail/ngx_mail_auth_http_module.c b/src/mail/ngx_mail_auth_http_module.c
> index 543d1c4eb..55280d66c 100644
> --- a/src/mail/ngx_mail_auth_http_module.c
> +++ b/src/mail/ngx_mail_auth_http_module.c
> @@ -981,6 +981,7 @@ ngx_mail_auth_sleep_handler(ngx_event_t *rev)
>  
>          s->mail_state = 0;
>          s->auth_method = NGX_MAIL_AUTH_PLAIN;
> +        s->tag.len = 0;
>  
>          c->log->action = "in auth state";
>  

Looks good to me.
Committed with minimal fixes to commit log, thanks.

-- 
Maxim Dounin
http://mdounin.ru/



More information about the nginx-devel mailing list