Skip to content

Mail: clear auth HTTP ctx before pool cleanup#32

Open
xintenseapple wants to merge 1 commit into
freenginx:defaultfrom
xintenseapple:fix/issue-23-mail-auth-http-stale-ctx
Open

Mail: clear auth HTTP ctx before pool cleanup#32
xintenseapple wants to merge 1 commit into
freenginx:defaultfrom
xintenseapple:fix/issue-23-mail-auth-http-stale-ctx

Conversation

@xintenseapple

Copy link
Copy Markdown

Summary:

  • Route mail auth HTTP cleanup through helpers that clear the session module context before destroying the temporary pool, and guard blocked client reads against a cleared context.

Verification:

  • git diff --check; ./auto/configure --with-mail --without-http; make -j2

Fixes #23

@mdounin

mdounin commented Jun 10, 2026

Copy link
Copy Markdown
Member

Clearing auth_http context and checking if it is set before accessing in ngx_mail_auth_http_block_read(), as the patch does, fixes the freed memory access.

The issue, however, remains: if the context is already freed and then ngx_mail_auth_http_block_read() is called, we've already queued an error message to the client (and probably placed some parts of it to the socket buffer), and calling ngx_mail_session_internal_server_error(), as in the patch, will discard the unsent part of the error message, and queue yet another error message for sending.

As suggested earlier in #23, a better fix would be to properly block reading when ngx_mail_send() is called with s->quit set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mail auth HTTP can leave a stale session ctx after temp-pool destroy

2 participants