the packet format is described in send_client_reply_packet() */
| 14380 | |
| 14381 | /* the packet format is described in send_client_reply_packet() */ |
| 14382 | static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio, |
| 14383 | uchar **buff, ulong pkt_len) |
| 14384 | { |
| 14385 | #ifndef EMBEDDED_LIBRARY |
| 14386 | THD *thd= mpvio->auth_info.thd; |
| 14387 | NET *net= &thd->net; |
| 14388 | char *end; |
| 14389 | DBUG_ASSERT(mpvio->status == MPVIO_EXT::FAILURE); |
| 14390 | |
| 14391 | if (pkt_len < MIN_HANDSHAKE_SIZE) |
| 14392 | return packet_error; |
| 14393 | |
| 14394 | /* |
| 14395 | Protocol buffer is guaranteed to always end with \0. (see my_net_read()) |
| 14396 | As the code below depends on this, lets check that. |
| 14397 | */ |
| 14398 | DBUG_ASSERT(net->read_pos[pkt_len] == 0); |
| 14399 | |
| 14400 | ulonglong client_capabilities= uint2korr(net->read_pos); |
| 14401 | compile_time_assert(sizeof(client_capabilities) >= 8); |
| 14402 | if (client_capabilities & CLIENT_PROTOCOL_41) |
| 14403 | { |
| 14404 | if (pkt_len < 32) |
| 14405 | return packet_error; |
| 14406 | client_capabilities|= ((ulong) uint2korr(net->read_pos+2)) << 16; |
| 14407 | if (!(client_capabilities & CLIENT_MYSQL)) |
| 14408 | { |
| 14409 | // it is client with mariadb extensions |
| 14410 | ulonglong ext_client_capabilities= |
| 14411 | (((ulonglong)uint4korr(net->read_pos + 28)) << 32); |
| 14412 | client_capabilities|= ext_client_capabilities; |
| 14413 | } |
| 14414 | } |
| 14415 | |
| 14416 | /* Disable those bits which are not supported by the client. */ |
| 14417 | compile_time_assert(sizeof(thd->client_capabilities) >= 8); |
| 14418 | thd->client_capabilities&= client_capabilities; |
| 14419 | |
| 14420 | DBUG_PRINT("info", ("client capabilities: %llu", thd->client_capabilities)); |
| 14421 | if (thd->client_capabilities & CLIENT_SSL) |
| 14422 | { |
| 14423 | unsigned long errptr __attribute__((unused)); |
| 14424 | |
| 14425 | /* Do the SSL layering. */ |
| 14426 | if (!ssl_acceptor_fd) |
| 14427 | return packet_error; |
| 14428 | |
| 14429 | DBUG_PRINT("info", ("IO layer change in progress...")); |
| 14430 | mysql_rwlock_rdlock(&LOCK_ssl_refresh); |
| 14431 | int ssl_ret = sslaccept(ssl_acceptor_fd, net->vio, net->read_timeout, &errptr); |
| 14432 | mysql_rwlock_unlock(&LOCK_ssl_refresh); |
| 14433 | ssl_acceptor_stats_update(ssl_ret); |
| 14434 | |
| 14435 | if(ssl_ret) |
| 14436 | { |
| 14437 | DBUG_PRINT("error", ("Failed to accept new SSL connection")); |
| 14438 | return packet_error; |
| 14439 | } |
no test coverage detected