| 1 |
# |
| 2 |
# MDEV-38550: COM_CHANGE_USER with Long Password Corrupts Database Name |
| 3 |
# |
| 4 |
# When password > 255 bytes with COM_CHANGE_USER, the password length was |
| 5 |
# truncated to a single byte, causing the server to read garbage as the |
| 6 |
# database name. |
| 7 |
# |
| 8 |
# Fix: Add LENENC support for COM_CHANGE_USER password field in both |
| 9 |
# client (libmariadb) and server (sql_acl.cc). |
| 10 |
# |
| 11 |
|
| 12 |
--source include/not_embedded.inc |
| 13 |
--source include/have_plugin_auth.inc |
| 14 |
|
| 15 |
--echo # |
| 16 |
--echo # Setup |
| 17 |
--echo # |
| 18 |
CREATE DATABASE mdev38550_db; |
| 19 |
|
| 20 |
--echo # |
| 21 |
--echo # Test 1: COM_CHANGE_USER with short password |
| 22 |
--echo # Verify mysql_change_user() works correctly with database parameter |
| 23 |
--echo # |
| 24 |
CREATE USER changeusertest IDENTIFIED VIA cleartext_plugin_server USING 'changepwd'; |
| 25 |
GRANT ALL ON *.* TO changeusertest; |
| 26 |
|
| 27 |
# Use change_user command to switch user with password and database |
| 28 |
change_user changeusertest,changepwd,mdev38550_db; |
| 29 |
SELECT DATABASE() AS db; |
| 30 |
change_user root; |
| 31 |
|
| 32 |
--echo # |
| 33 |
--echo # Test 2: COM_CHANGE_USER with long password (260 bytes) |
| 34 |
--echo # This works because auth plugin switching sends password in a SECOND packet |
| 35 |
--echo # (via ma_net_write), bypassing the 255-byte limit in send_change_user_packet() |
| 36 |
--echo # |
| 37 |
--echo # Note: If connection used cleartext directly (no auth switch), it would fail |
| 38 |
--echo # due to libmariadb's 255-byte limit in send_change_user_packet() |
| 39 |
--echo # |
| 40 |
--let $change_pwd=`SELECT REPEAT('c', 260)` |
| 41 |
eval CREATE USER changeuserlongpwd IDENTIFIED VIA cleartext_plugin_server USING '$change_pwd'; |
| 42 |
GRANT ALL ON *.* TO changeuserlongpwd; |
| 43 |
|
| 44 |
change_user changeuserlongpwd,$change_pwd,mdev38550_db; |
| 45 |
SELECT DATABASE() AS db; |
| 46 |
change_user root; |
| 47 |
|
| 48 |
--echo # |
| 49 |
--echo # Test 3: COM_CHANGE_USER with long password - no auth switch |
| 50 |
--echo # Connection uses cleartext directly, password goes in first packet |
| 51 |
--echo # Requires LENENC support in both client and server for COM_CHANGE_USER |
| 52 |
--echo # |
| 53 |
--connect (cleartext_con, 127.0.0.1, changeuserlongpwd, $change_pwd, mdev38550_db, $MASTER_MYPORT, , , mysql_clear_password) |
| 54 |
SELECT DATABASE() AS db, CURRENT_USER() AS user; |
| 55 |
change_user changeuserlongpwd,$change_pwd,mdev38550_db; |
| 56 |
SELECT DATABASE() AS db, CURRENT_USER() AS user; |
| 57 |
--connection default |
| 58 |
--disconnect cleartext_con |
| 59 |
|
| 60 |
--echo # |
| 61 |
--echo # Cleanup |
| 62 |
--echo # |
| 63 |
DROP USER changeusertest, changeuserlongpwd; |
| 64 |
DROP DATABASE mdev38550_db; |