Commit f83839a4 authored by Chuck Bell's avatar Chuck Bell

Merge with main

parents b7478b96 7822b78d
...@@ -8820,24 +8820,18 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio, ...@@ -8820,24 +8820,18 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
/** /**
Make sure that when sending plugin supplued data to the client they Make sure that when sending plugin supplied data to the client they
are not considered a special out-of-band command, like e.g. are not considered a special out-of-band command, like e.g.
\255 (error) or \254 (change user request packet). \255 (error) or \254 (change user request packet) or \0 (OK).
To avoid this we send plugin data packets starting with one of these To avoid this the server will send all plugin data packets "wrapped"
2 bytes "wrapped" in a command \1. in a command \1.
For the above reason we have to wrap plugin data packets starting with Note that the client will continue sending its replies unrwapped.
\1 as well.
*/ */
#define IS_OUT_OF_BAND_PACKET(packet,packet_len) \
((packet_len) > 0 && \
(*(packet) == 1 || *(packet) == 255 || *(packet) == 254))
static inline int static inline int
wrap_plguin_data_into_proper_command(NET *net, wrap_plguin_data_into_proper_command(NET *net,
const uchar *packet, int packet_len) const uchar *packet, int packet_len)
{ {
DBUG_ASSERT(IS_OUT_OF_BAND_PACKET(packet, packet_len));
return net_write_command(net, 1, (uchar *) "", 0, packet, packet_len); return net_write_command(net, 1, (uchar *) "", 0, packet, packet_len);
} }
...@@ -8874,13 +8868,8 @@ static int server_mpvio_write_packet(MYSQL_PLUGIN_VIO *param, ...@@ -8874,13 +8868,8 @@ static int server_mpvio_write_packet(MYSQL_PLUGIN_VIO *param,
res= send_server_handshake_packet(mpvio, (char*) packet, packet_len); res= send_server_handshake_packet(mpvio, (char*) packet, packet_len);
else if (mpvio->status == MPVIO_EXT::RESTART) else if (mpvio->status == MPVIO_EXT::RESTART)
res= send_plugin_request_packet(mpvio, packet, packet_len); res= send_plugin_request_packet(mpvio, packet, packet_len);
else if (IS_OUT_OF_BAND_PACKET(packet, packet_len))
res= wrap_plguin_data_into_proper_command(mpvio->net, packet, packet_len);
else else
{ res= wrap_plguin_data_into_proper_command(mpvio->net, packet, packet_len);
res= my_net_write(mpvio->net, packet, packet_len) ||
net_flush(mpvio->net);
}
mpvio->packets_written++; mpvio->packets_written++;
DBUG_RETURN(res); DBUG_RETURN(res);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment