| 15521 | } |
| 15522 | |
| 15523 | static int old_password_authenticate(MYSQL_PLUGIN_VIO *vio, |
| 15524 | MYSQL_SERVER_AUTH_INFO *info) |
| 15525 | { |
| 15526 | uchar *pkt; |
| 15527 | int pkt_len; |
| 15528 | MPVIO_EXT *mpvio= (MPVIO_EXT *) vio; |
| 15529 | THD *thd=info->thd; |
| 15530 | |
| 15531 | /* generate the scramble, or reuse the old one */ |
| 15532 | if (thd->scramble[SCRAMBLE_LENGTH]) |
| 15533 | thd_create_random_password(thd, thd->scramble, SCRAMBLE_LENGTH); |
| 15534 | /* and send it to the client */ |
| 15535 | if (mpvio->write_packet(mpvio, (uchar*)thd->scramble, SCRAMBLE_LENGTH + 1)) |
| 15536 | return CR_AUTH_HANDSHAKE; |
| 15537 | |
| 15538 | /* read the reply and authenticate */ |
| 15539 | if ((pkt_len= mpvio->read_packet(mpvio, &pkt)) < 0) |
| 15540 | return CR_AUTH_HANDSHAKE; |
| 15541 | |
| 15542 | #ifdef NO_EMBEDDED_ACCESS_CHECKS |
| 15543 | return CR_OK; |
| 15544 | #endif |
| 15545 | |
| 15546 | /* |
| 15547 | legacy: if switch_from_long_to_short_scramble, |
| 15548 | the password is sent \0-terminated, the pkt_len is always 9 bytes. |
| 15549 | We need to figure out the correct scramble length here. |
| 15550 | */ |
| 15551 | if (pkt_len == SCRAMBLE_LENGTH_323 + 1) |
| 15552 | pkt_len= (int)strnlen((char*)pkt, pkt_len); |
| 15553 | |
| 15554 | if (pkt_len == 0) /* no password */ |
| 15555 | return info->auth_string_length ? CR_AUTH_USER_CREDENTIALS : CR_OK; |
| 15556 | |
| 15557 | if (secure_auth(thd)) |
| 15558 | return CR_AUTH_HANDSHAKE; |
| 15559 | |
| 15560 | info->password_used= PASSWORD_USED_YES; |
| 15561 | |
| 15562 | if (pkt_len == SCRAMBLE_LENGTH_323) |
| 15563 | { |
| 15564 | if (!info->auth_string_length) |
| 15565 | return CR_AUTH_USER_CREDENTIALS; |
| 15566 | |
| 15567 | return check_scramble_323(pkt, thd->scramble, (ulong *) info->auth_string) |
| 15568 | ? CR_AUTH_USER_CREDENTIALS : CR_OK; |
| 15569 | } |
| 15570 | |
| 15571 | my_error(ER_HANDSHAKE_ERROR, MYF(0)); |
| 15572 | return CR_AUTH_HANDSHAKE; |
| 15573 | } |
| 15574 | |
| 15575 | static int old_password_make_scramble(const char *password, |
| 15576 | size_t password_length, char *hash, size_t *hash_length) |
nothing calls this directly
no test coverage detected