Skip to content

Conversation

@rophy
Copy link

@rophy rophy commented Jan 12, 2026

Follow up of #4509, which focuses on auth switch. This PR focuses on COM_CHANGE_USER.

When password >= 251 bytes, LENENC uses 3-byte prefix (0xFC + 2 bytes),
but the old code assumed 1-byte prefix with 'db + passwd_len + 1'.

Fix: use 'passwd + passwd_len' since passwd has already been advanced
past the length prefix by safe_net_field_length_ll().
Add regression test for auth switch with long password bug.

The test verifies that connecting with passwords >= 251 bytes
(which triggers 3-byte LENENC encoding) correctly preserves
the database name during authentication plugin switching.

Test cases:
- Short password baseline (7 bytes)
- Long password (260 bytes) - triggers 3-byte LENENC
- Very long password (500 bytes)
Use double quotes instead of single quotes for password arguments
in --exec commands to work on both Unix and Windows platforms.
Add tests for mysql_change_user() with database parameter:
- Test 4: Short password - verifies basic COM_CHANGE_USER works
- Test 5: Long password (260 bytes) - verifies LENENC encoding path
Test 5 explains why 260-byte password works with auth switching.
Test 6 (disabled) documents the libmariadb 255-byte limit that would
crash in debug builds or return ERROR 2027 in release builds.
Add CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA support to parse_com_change_user_packet()
to allow passwords longer than 255 bytes in COM_CHANGE_USER packets.

Previously, parse_com_change_user_packet() only supported single-byte length
encoding (max 255 bytes), while parse_client_handshake_packet() supported LENENC.

This change mirrors the fix in libmariadb's send_change_user_packet() and enables
Test 6 which verifies COM_CHANGE_USER with 260-byte passwords without auth switching.
The comment was incorrect - the plugin is installed by the test itself
with INSTALL PLUGIN IF NOT EXISTS, not preloaded by MTR.
…NECTION

When CLIENT_SECURE_CONNECTION is not set, the password is null-terminated
and the passwd pointer is not incremented, so we need +1 to skip past the
null terminator when calculating the db pointer.
@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Jan 12, 2026
@vuvova vuvova self-requested a review January 13, 2026 11:44
Copy link
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

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

Please use https://jira.mariadb.org/browse/MDEV-38550 instead of the original one.

@rophy
Copy link
Author

rophy commented Jan 14, 2026

Will continue working on this after #4509 got merged.

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

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

2 participants