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)
arnaud-lb added a commit to heathdutton/php-src that referenced this pull request Oct 15, 2026
* up/PHP-8.4: (3595 commits)
  Fix Windows quoting in proc_open tests (php#24343)
  Pin macOS CI to OpenSSL 3 (php#24332)
  Zend: zend_call_stack_get_netbsd_pthread() pthread attribute leak.
  Revert "ext/standard/tests: work around Windows quoting with tempfiles."
  Update NEWS
  ext/standard/tests: work around Windows quoting with tempfiles.
  .github/scripts/windows: pass an extension_dir to the test runner.
  {ext/standard,sapi/cli}/tests: pass TEST_PHP_EXTRA_ARGS to php
  ext/standard/tests: pass TEST_PHP_EXTRA_ARGS to some proc_open() tests
  sapi/cli/tests/023.phpt: support TEST_PHP_EXTRA_ARGS
  std: Fix memory leak of the last response headers after a nested HTTP request (php#24201)
  Fiber: hold the object a callable resolved to in the creating frame (php#24134)
  Fix v142 ARM64 hash and floating point results (php#24317)
  Use the default archive names for Windows ARM64 builds (php#24313)
  ext/gd: Drop useless and doubtful MSVC specific code (libgd/libgd@f1480ab) (php#24316)
  ext/session: do not reuse session state a save handler tore down
  Fix phpGH-24293: Segfault with an empty password in MariaDB PAM (php#24294)
  Fix phpGH-24289: finfo::file() reports the wrong argument number
  Fix phpGH-24260: querySelectorAll() returns duplicate elements for selector lists
  Fix escape analysis for objects implementing ArrayAccess
  ...
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