MXS-2324: Prevent stack overflow with large results

If a result consists of only OK packets, they would be processed
recursively which most of the time leads to a stack overflow. This can be
prevented by consuming all OK packets in the result in one go.
This commit is contained in:
Markus Mäkelä 2019-03-18 12:58:02 +02:00
parent a6f52b008f
commit 0b77c3f05f
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -192,6 +192,14 @@ void RWBackend::process_reply(GWBUF* buffer)
// TODO: Don't clone the buffer
GWBUF* tmp = gwbuf_clone(buffer);
tmp = gwbuf_consume(tmp, mxs_mysql_get_packet_len(tmp));
// Consume repeating OK packets
while (mxs_mysql_more_results_after_ok(buffer) && have_next_packet(tmp))
{
tmp = gwbuf_consume(tmp, mxs_mysql_get_packet_len(tmp));
mxb_assert(tmp);
}
process_reply(tmp);
gwbuf_free(tmp);
return;