Bug #104323 mysql change user authentication error
Submitted: 15 Jul 2021 7:46 Modified: 15 Jul 2021 10:37
Reporter: chao xie Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S3 (Non-critical)
Version:5.7 OS:Any
Assigned to: CPU Architecture:Any

[15 Jul 2021 7:46] chao xie
Description:
I user mysql_change_user in my program, it works for mysql server 8.0.

But i got an error 1045 if i use mysql server 5.7.

After debug, i found that the bug is in function parse_com_change_user_packet(sql/auth/sql_authentication.cc:1113), after reading the client_plugin, it didn't move pos of the ptr, bug mysql server 8.0 did it.

could you fix it in mysql server 5.7? 

How to repeat:
Reference the description

Suggested fix:
source code in 5.7.34, sql/auth/sql_authentication.cc:1113
  if (protocol->has_client_capability(CLIENT_PLUGIN_AUTH))
  {
    client_plugin= ptr + 2;
    if (client_plugin >= end)
    {
      my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
      DBUG_RETURN(1);
    }
  }

source code in 8.0.22, sql/auth/sql_authentication.cc:2191
  if (protocol->has_client_capability(CLIENT_PLUGIN_AUTH)) {
    client_plugin = ptr + 2;
    /*
      ptr needs to be updated to point to correct position so that
      connection attributes are read properly.
    */
    ptr = ptr + 2 + strlen(client_plugin) + 1;

    if (client_plugin >= end) {
      my_error(ER_UNKNOWN_COM_ERROR, MYF(0));
      return true;
    }
  }
[15 Jul 2021 10:37] MySQL Verification Team
Hi Mr. xie,

Thank you for your bug report.

We have reviewed your code analysis and we agree that this could be ported back to 5.7. However, further analysis will be necessary by a team in charge.

Verified as reported.