Skip to content

lib-sasl: Avoid null pointer in empty response check - #310

Open
srkyn wants to merge 1 commit into
dovecot:mainfrom
srkyn:fix/sasl-empty-response-nul-check
Open

lib-sasl: Avoid null pointer in empty response check#310
srkyn wants to merge 1 commit into
dovecot:mainfrom
srkyn:fix/sasl-empty-response-nul-check

Conversation

@srkyn

@srkyn srkyn commented Aug 25, 2026

Copy link
Copy Markdown

sasl_server_request_initial() permits a null data pointer when the response size is zero. This is the normal no-initial-response case used by mechanisms such as LOGIN and CRAM-MD5. The NUL check still passed that pointer to memchr(), which is undefined by the C library contract even with a zero length and is reported by UBSan.

Skip the scan when the response is empty. Non-empty response handling is unchanged.

Tests:

  • Current base: b2b2d74e0900e3e3d0ba0392fac9c4cce989aab1
  • test-sasl-authentication: 533 tests passed with Clang UBSan, with the unrelated function-type sanitizer disabled
  • test-sasl-authentication: 533 tests passed with GCC
  • POP3 loopback AUTH LOGIN: normal challenge, no UBSan diagnostic
  • POP3 loopback mutation campaign: 5,000 sessions, no sanitizer diagnostic

The SASL request API permits a NULL data pointer when the response size is zero. Skip the NUL scan for that empty-input case so the supported no-initial-response path does not pass NULL to memchr.

Signed-off-by: David Sarkisyan <david@srkyn.com>
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.

1 participant