From 23843ed6ee79e361ed27ca9736f46cf710f0f82e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Thu, 21 Jan 2021 18:14:24 +0000 Subject: [PATCH] Fixed invalid writes/reads in 'update_group_replication_set_writer' due to query not fitting allocated buffer --- lib/MySQL_HostGroups_Manager.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index e3540cb19..daeb40434 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -4699,6 +4699,8 @@ void MySQL_HostGroups_Manager::update_group_replication_set_writer(char *_hostna //free(query); if (writer_is_also_reader && read_HG>=0) { q=(char *)"INSERT OR IGNORE INTO mysql_servers_incoming (hostgroup_id,hostname,port,gtid_port,status,weight,compression,max_connections,max_replication_lag,use_ssl,max_latency_ms,comment) SELECT %d,hostname,port,gtid_port,status,weight,compression,max_connections,max_replication_lag,use_ssl,max_latency_ms,comment FROM mysql_servers_incoming WHERE hostgroup_id=%d AND hostname='%s' AND port=%d"; + free(query); + query=(char *)malloc(strlen(q)+strlen(_hostname)+256); sprintf(query,q,read_HG,_writer_hostgroup,_hostname,_port); mydb->execute(query); }