diff --git a/modules/protocol/mysql_client.c b/modules/protocol/mysql_client.c index f1e0be00f..26dac0861 100644 --- a/modules/protocol/mysql_client.c +++ b/modules/protocol/mysql_client.c @@ -410,7 +410,7 @@ MySQLSendHandshake(DCB* dcb) mysql_handshake_payload = mysql_handshake_payload + sizeof(mysql_protocol_version); // write server version plus 0 filler - memcpy(mysql_handshake_payload, GW_MYSQL_VERSION, strlen(GW_MYSQL_VERSION)); + strcpy(mysql_handshake_payload, GW_MYSQL_VERSION); mysql_handshake_payload = mysql_handshake_payload + strlen(GW_MYSQL_VERSION); *mysql_handshake_payload = 0x00; @@ -527,7 +527,7 @@ static int gw_mysql_do_authentication(DCB *dcb, GWBUF *queue) { compress = GW_MYSQL_CAPABILITIES_COMPRESS & gw_mysql_get_byte4(&protocol->client_capabilities); // now get the user - strcpy(username, (char *)(client_auth_packet + 4 + 4 + 4 + 1 + 23)); + strncpy(username, client_auth_packet + 4 + 4 + 4 + 1 + 23, 128); fprintf(stderr, "<<< Client username is [%s]\n", username); // get the auth token len @@ -535,7 +535,7 @@ static int gw_mysql_do_authentication(DCB *dcb, GWBUF *queue) { if (connect_with_db) { database = client_data->db; - strcpy(database, (char *)(client_auth_packet + 4 + 4 + 4 + 1 + 23 + strlen(username) + 1 + 1 + auth_token_len)); + strncpy(database, client_auth_packet + 4 + 4 + 4 + 1 + 23 + strlen(username) + 1 + 1 + auth_token_len, 128); fprintf(stderr, "<<< Client selected db is [%s]\n", database); } else { fprintf(stderr, "<<< Client is NOT connected with db\n"); @@ -769,7 +769,10 @@ int gw_read_client_event(DCB* dcb) { ROUTER *router_instance = NULL; void *rsession = NULL; MySQLProtocol *protocol = NULL; + uint8_t buffer[MAX_BUFFER_SIZE] = ""; int b = -1; + GWBUF *head = NULL; + GWBUF *gw_buffer = NULL; if (dcb) { protocol = DCB_PROTOCOL(dcb, MySQLProtocol); @@ -984,7 +987,7 @@ int gw_write_client_event(DCB *dcb) { } /// -// set listener for mysql protocol +// set listener for mysql protocol, retur 1 on success and 0 in failure /// int gw_MySQLListener(DCB *listener, char *config_bind) { int l_so;