From 2f2e385185b132a4f24679f145ffe2aef58f7733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Tue, 13 Dec 2022 19:42:07 +0100 Subject: [PATCH 1/4] Fix delete call on pointer to incomplete type 'ProxySQL_Node_Address' Deleting a pointer to an incomplete type may cause undefined behavior --- lib/MySQL_Session.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index 089db49f89..93da82c92b 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -19,6 +19,7 @@ #include "MySQL_Protocol.h" #include "SQLite3_Server.h" #include "MySQL_Variables.h" +#include "ProxySQL_Cluster.hpp" #include "libinjection.h" From 2ecbad32448e06ec61910b5fafb18b322407e4d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Tue, 13 Dec 2022 19:44:19 +0100 Subject: [PATCH 2/4] Fix warning due to catching of polymorphic type by value --- lib/MySQL_Logger.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/MySQL_Logger.cpp b/lib/MySQL_Logger.cpp index 509df0375d..61fba5f680 100644 --- a/lib/MySQL_Logger.cpp +++ b/lib/MySQL_Logger.cpp @@ -542,7 +542,7 @@ void MySQL_Logger::events_open_log_unlocked() { events.logfile->open(filen , std::ios::out | std::ios::binary); proxy_info("Starting new mysql event log file %s\n", filen); } - catch (std::ofstream::failure e) { + catch (const std::ofstream::failure&) { proxy_error("Error creating new mysql event log file %s\n", filen); delete events.logfile; events.logfile=NULL; @@ -571,7 +571,7 @@ void MySQL_Logger::audit_open_log_unlocked() { audit.logfile->open(filen , std::ios::out | std::ios::binary); proxy_info("Starting new audit log file %s\n", filen); } - catch (std::ofstream::failure e) { + catch (const std::ofstream::failure&) { proxy_error("Error creating new audit log file %s\n", filen); delete audit.logfile; audit.logfile=NULL; From 1abb4d7605303f34a6b87c07d9e86d8e38a0c5de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Tue, 13 Dec 2022 19:52:03 +0100 Subject: [PATCH 3/4] Comment out several currently unused variables --- lib/MySQL_HostGroups_Manager.cpp | 4 ++-- lib/ProxySQL_Cluster.cpp | 12 ++++++------ lib/ProxySQL_RESTAPI_Server.cpp | 8 +++++++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index 0d21e11b87..b32fa8852f 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -3662,7 +3662,7 @@ void MySQL_HostGroups_Manager::group_replication_lag_action( wrlock(); int reader_hostgroup = 0; - bool writer_is_also_reader = false; + // bool writer_is_also_reader = false; // Get the reader_hostgroup for the supplied writter hostgroup const std::string t_reader_hostgroup_query { @@ -3688,7 +3688,7 @@ void MySQL_HostGroups_Manager::group_replication_lag_action( rhid_row = rhid_res->rows[0]; reader_hostgroup = atoi(rhid_row->fields[0]); - writer_is_also_reader = atoi(rhid_row->fields[1]); + // writer_is_also_reader = atoi(rhid_row->fields[1]); { MyHGC* myhgc = nullptr; diff --git a/lib/ProxySQL_Cluster.cpp b/lib/ProxySQL_Cluster.cpp index 7c2dd9f1d7..6e6d29877f 100644 --- a/lib/ProxySQL_Cluster.cpp +++ b/lib/ProxySQL_Cluster.cpp @@ -87,7 +87,7 @@ void * ProxySQL_Cluster_Monitor_thread(void *args) { GloProxyCluster->get_credentials(&username, &password); if (strlen(username)) { // do not monitor if the username is empty unsigned int timeout = 1; - unsigned int timeout_long = 60; + // unsigned int timeout_long = 60; if (conn == NULL) { conn = mysql_init(NULL); if (conn==NULL) { @@ -906,7 +906,7 @@ void ProxySQL_Cluster::pull_mysql_query_rules_from_peer(const string& expected_c GloProxyCluster->get_credentials(&username, &password); if (strlen(username)) { // do not monitor if the username is empty unsigned int timeout = 1; - unsigned int timeout_long = 60; + // unsigned int timeout_long = 60; mysql_options(conn, MYSQL_OPT_CONNECT_TIMEOUT, &timeout); //mysql_options(conn, MYSQL_OPT_READ_TIMEOUT, &timeout_long); //mysql_options(conn, MYSQL_OPT_WRITE_TIMEOUT, &timeout); @@ -1177,7 +1177,7 @@ void ProxySQL_Cluster::pull_mysql_users_from_peer(const string& expected_checksu GloProxyCluster->get_credentials(&username, &password); if (strlen(username)) { // do not monitor if the username is empty unsigned int timeout = 1; - unsigned int timeout_long = 60; + // unsigned int timeout_long = 60; mysql_options(conn, MYSQL_OPT_CONNECT_TIMEOUT, &timeout); //mysql_options(conn, MYSQL_OPT_READ_TIMEOUT, &timeout_long); //mysql_options(conn, MYSQL_OPT_WRITE_TIMEOUT, &timeout); @@ -1498,7 +1498,7 @@ void ProxySQL_Cluster::pull_mysql_servers_from_peer(const std::string& checksum, GloProxyCluster->get_credentials(&username, &password); if (strlen(username)) { // do not monitor if the username is empty unsigned int timeout = 1; - unsigned int timeout_long = 60; + // unsigned int timeout_long = 60; mysql_options(conn, MYSQL_OPT_CONNECT_TIMEOUT, &timeout); //mysql_options(conn, MYSQL_OPT_READ_TIMEOUT, &timeout_long); //mysql_options(conn, MYSQL_OPT_WRITE_TIMEOUT, &timeout); @@ -1868,7 +1868,7 @@ void ProxySQL_Cluster::pull_global_variables_from_peer(const string& var_type, c GloProxyCluster->get_credentials(&username, &password); if (strlen(username)) { // do not monitor if the username is empty unsigned int timeout = 1; - unsigned int timeout_long = 60; + // unsigned int timeout_long = 60; mysql_options(conn, MYSQL_OPT_CONNECT_TIMEOUT, &timeout); //mysql_options(conn, MYSQL_OPT_READ_TIMEOUT, &timeout_long); //mysql_options(conn, MYSQL_OPT_WRITE_TIMEOUT, &timeout); @@ -2020,7 +2020,7 @@ void ProxySQL_Cluster::pull_proxysql_servers_from_peer(const std::string& expect GloProxyCluster->get_credentials(&username, &password); if (strlen(username)) { // do not monitor if the username is empty unsigned int timeout = 1; - unsigned int timeout_long = 60; + // unsigned int timeout_long = 60; mysql_options(conn, MYSQL_OPT_CONNECT_TIMEOUT, &timeout); //mysql_options(conn, MYSQL_OPT_READ_TIMEOUT, &timeout_long); //mysql_options(conn, MYSQL_OPT_WRITE_TIMEOUT, &timeout); diff --git a/lib/ProxySQL_RESTAPI_Server.cpp b/lib/ProxySQL_RESTAPI_Server.cpp index 94374f204b..bda6770e95 100644 --- a/lib/ProxySQL_RESTAPI_Server.cpp +++ b/lib/ProxySQL_RESTAPI_Server.cpp @@ -290,19 +290,25 @@ class sync_resource : public http_resource { input_params.push_back({arg.first, arg.second}); } - const char* req_path { req.get_path().c_str() }; const string s_params { input_params.dump() }; + +#ifdef DEBUG + const char* req_path { req.get_path().c_str() }; const char* p_params { s_params.c_str() }; proxy_debug(PROXY_DEBUG_RESTAPI, 1, "Processing GET - req: '%s', params: `%s`\n", req_path, p_params); +#endif return process_request(req, s_params); } const std::shared_ptr render_POST(const http_request& req) { std::string params=req.get_content(); + +#ifdef DEBUG const char* req_path { req.get_path().c_str() }; const char* p_params { params.c_str() }; proxy_debug(PROXY_DEBUG_RESTAPI, 1, "Processing POST - req: '%s', params: `%s`\n", req_path, p_params); +#endif return process_request(req, params); } From 6f163f8935a021d2e120748ed520c3d49874315e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Tue, 13 Dec 2022 19:52:53 +0100 Subject: [PATCH 4/4] Fix potentially uninitialized variable --- lib/ProxySQL_RESTAPI_Server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ProxySQL_RESTAPI_Server.cpp b/lib/ProxySQL_RESTAPI_Server.cpp index bda6770e95..795112b9c4 100644 --- a/lib/ProxySQL_RESTAPI_Server.cpp +++ b/lib/ProxySQL_RESTAPI_Server.cpp @@ -118,7 +118,7 @@ class sync_resource : public http_resource { } std::string script; - int interval_ms; + int interval_ms = 1; auto result=find_script(req, script, interval_ms); // result == nullpts means that script was found and we can execute it. continue.