From 1287b0e595a5f99026f66df7eeaef091b8ffc774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Mon, 30 Oct 2017 12:20:18 +0200 Subject: [PATCH] Backport authentication fix from 2.2 The authentication code assumed that the initial request only had authentication related data. This is not true if the client library predicts that the authentication will succeed and it sends a query right after it sends the authentication data. --- .../protocol/MySQL/MySQLClient/mysql_client.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/server/modules/protocol/MySQL/MySQLClient/mysql_client.c b/server/modules/protocol/MySQL/MySQLClient/mysql_client.c index a25b329d0..830c88d9a 100644 --- a/server/modules/protocol/MySQL/MySQLClient/mysql_client.c +++ b/server/modules/protocol/MySQL/MySQLClient/mysql_client.c @@ -502,17 +502,12 @@ int gw_read_client_event(DCB* dcb) * */ case MXS_AUTH_STATE_MESSAGE_READ: - /* After this call read_buffer will point to freed data */ - if (nbytes_read < 3 || (0 == max_bytes && nbytes_read < - (MYSQL_GET_PAYLOAD_LEN((uint8_t *) GWBUF_DATA(read_buffer)) + 4)) || - (0 != max_bytes && nbytes_read < max_bytes)) + dcb->dcb_readqueue = gwbuf_append(dcb->dcb_readqueue, read_buffer); + + if ((read_buffer = modutil_get_next_MySQL_packet(&dcb->dcb_readqueue))) { - - dcb->dcb_readqueue = read_buffer; - - return 0; + return_code = gw_read_do_authentication(dcb, read_buffer, gwbuf_length(read_buffer)); } - return_code = gw_read_do_authentication(dcb, read_buffer, nbytes_read); break; /**