Skip to content

Fix GH-24293: Segfault on connect with empty password to MariaDB PAM - #24294

Closed
lazerg wants to merge 3 commits into
php:PHP-8.4from
lazerg:fix/gh-24293
Closed

lazerg wants to merge 3 commits into
php:PHP-8.4from
lazerg:fix/gh-24293

Conversation

@lazerg

@lazerg lazerg commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

With an empty password, mysqlnd_pam_auth_get_auth_data() returned NULL but still set the length to 1 for the trailing NUL added in bug #78680, so php_mysqlnd_change_auth_response_write() copied a byte from a NULL pointer once the server switched to mysql_clear_password. The buffer is now always allocated, so an empty password goes out as a single NUL byte. I checked it against MariaDB 11.4 with the PAM setup from the issue; there's no test since CI has no MariaDB with PAM.

Fixes GH-24293

@LamentXU123 LamentXU123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me!
Please add a regression test.

@lazerg

lazerg commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Added a regression test in 5612eba. It uses the mysqli fake server to send a mysql_clear_password auth switch, so it runs in CI without a PAM setup. Without the fix it segfaults.

@kamil-tekiela kamil-tekiela left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine.

@LamentXU123 LamentXU123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Will do another look before I merge but I think fine.

LamentXU123 added a commit that referenced this pull request Oct 13, 2026
* PHP-8.6:
  Fix GH-24293: Segfault with an empty password in MariaDB PAM (#24294)
iliaal pushed a commit to iliaal/php-src that referenced this pull request Oct 13, 2026
* PHP-8.4:
  Fix phpGH-24293: Segfault with an empty password in MariaDB PAM (php#24294)
iliaal pushed a commit to iliaal/php-src that referenced this pull request Oct 13, 2026
* PHP-8.5:
  Fix phpGH-24293: Segfault with an empty password in MariaDB PAM (php#24294)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants