MCPcopy Create free account
hub / github.com/MariaDB/server / parse_client_handshake_packet

Function parse_client_handshake_packet

sql/sql_acl.cc:14382–14683  ·  view source on GitHub ↗

the packet format is described in send_client_reply_packet() */

Source from the content-addressed store, hash-verified

14380
14381/* the packet format is described in send_client_reply_packet() */
14382static 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 }

Callers 1

server_mpvio_read_packetFunction · 0.85

Calls 15

uint2korrFunction · 0.85
uint4korrFunction · 0.85
sslacceptFunction · 0.85
my_net_readFunction · 0.85
inc_host_errorsFunction · 0.85
my_errorFunction · 0.85
thd_init_client_charsetFunction · 0.85
uint3korrFunction · 0.85
strendFunction · 0.85
safe_net_field_length_llFunction · 0.85

Tested by

no test coverage detected