Fix to MXS-209: https://mariadb.atlassian.net/browse/MXS-209
Added missing checks for proper column count on query result.
This commit is contained in:
@ -372,6 +372,13 @@ char *server_string;
|
||||
if (mysql_query(database->con, "SHOW STATUS LIKE 'wsrep_local_state'") == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
if(mysql_field_count(database->con) < 2)
|
||||
{
|
||||
mysql_free_result(result);
|
||||
skygw_log_write(LE,"Error: Malformed result for \"SHOW STATUS LIKE 'wsrep_local_state'\"");
|
||||
return;
|
||||
}
|
||||
|
||||
while ((row = mysql_fetch_row(result)))
|
||||
{
|
||||
if (strcmp(row[1], "4") == 0)
|
||||
@ -398,6 +405,14 @@ char *server_string;
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
long local_index = -1;
|
||||
|
||||
if(mysql_field_count(database->con) < 2)
|
||||
{
|
||||
mysql_free_result(result);
|
||||
skygw_log_write(LE,"Error: Malformed result for \"SHOW STATUS LIKE 'wsrep_local_index'\"");
|
||||
return;
|
||||
}
|
||||
|
||||
while ((row = mysql_fetch_row(result)))
|
||||
{
|
||||
local_index = strtol(row[1], NULL, 10);
|
||||
|
@ -367,6 +367,13 @@ char *server_string;
|
||||
{
|
||||
long server_id = -1;
|
||||
|
||||
if(mysql_field_count(database->con) != 1)
|
||||
{
|
||||
mysql_free_result(result);
|
||||
skygw_log_write(LE,"Error: Malformed result for 'SELECT @@server_id'.");
|
||||
return;
|
||||
}
|
||||
|
||||
while ((row = mysql_fetch_row(result)))
|
||||
{
|
||||
server_id = strtol(row[0], NULL, 10);
|
||||
@ -393,6 +400,14 @@ char *server_string;
|
||||
int i = 0;
|
||||
long master_id = -1;
|
||||
|
||||
if(mysql_field_count(database->con) < 42)
|
||||
{
|
||||
mysql_free_result(result);
|
||||
skygw_log_write(LE,"Error: SHOW ALL SLAVES STATUS "
|
||||
"returned less than the expected amount of rows.");
|
||||
return;
|
||||
}
|
||||
|
||||
while ((row = mysql_fetch_row(result)))
|
||||
{
|
||||
/* get Slave_IO_Running and Slave_SQL_Running values*/
|
||||
@ -432,6 +447,14 @@ char *server_string;
|
||||
{
|
||||
long master_id = -1;
|
||||
|
||||
if(mysql_field_count(database->con) < 40)
|
||||
{
|
||||
mysql_free_result(result);
|
||||
skygw_log_write(LE,"Error: SHOW SLAVE STATUS "
|
||||
"returned less than the expected amount of rows.");
|
||||
return;
|
||||
}
|
||||
|
||||
while ((row = mysql_fetch_row(result)))
|
||||
{
|
||||
/* get Slave_IO_Running and Slave_SQL_Running values*/
|
||||
@ -463,6 +486,12 @@ char *server_string;
|
||||
if (mysql_query(database->con, "SHOW GLOBAL VARIABLES LIKE 'read_only'") == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
if(mysql_field_count(database->con) < 2)
|
||||
{
|
||||
mysql_free_result(result);
|
||||
skygw_log_write(LE,"Error: Malformed result for \"SHOW GLOBAL VARIABLES LIKE 'read_only'\"");
|
||||
return;
|
||||
}
|
||||
|
||||
while ((row = mysql_fetch_row(result)))
|
||||
{
|
||||
|
@ -408,6 +408,12 @@ char *server_string;
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
long server_id = -1;
|
||||
if(mysql_field_count(database->con) != 1)
|
||||
{
|
||||
mysql_free_result(result);
|
||||
skygw_log_write(LE,"Error: Malformed result for 'SELECT @@server_id'.");
|
||||
return;
|
||||
}
|
||||
while ((row = mysql_fetch_row(result)))
|
||||
{
|
||||
server_id = strtol(row[0], NULL, 10);
|
||||
@ -433,6 +439,15 @@ char *server_string;
|
||||
{
|
||||
int i = 0;
|
||||
long master_id = -1;
|
||||
|
||||
if(mysql_field_count(database->con) < 42)
|
||||
{
|
||||
mysql_free_result(result);
|
||||
skygw_log_write(LE,"Error: SHOW ALL SLAVES STATUS "
|
||||
"returned less than the expected amount of rows.");
|
||||
return;
|
||||
}
|
||||
|
||||
while ((row = mysql_fetch_row(result)))
|
||||
{
|
||||
/* get Slave_IO_Running and Slave_SQL_Running values*/
|
||||
@ -471,6 +486,14 @@ char *server_string;
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
long master_id = -1;
|
||||
if(mysql_field_count(database->con) < 40)
|
||||
{
|
||||
mysql_free_result(result);
|
||||
skygw_log_write(LE,"Error: SHOW SLAVE STATUS "
|
||||
"returned less than the expected amount of rows.");
|
||||
return;
|
||||
}
|
||||
|
||||
while ((row = mysql_fetch_row(result)))
|
||||
{
|
||||
/* get Slave_IO_Running and Slave_SQL_Running values*/
|
||||
|
@ -323,6 +323,13 @@ char *server_string;
|
||||
if (mysql_query(database->con, "SHOW STATUS LIKE 'Ndb_number_of_ready_data_nodes'") == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
if(mysql_field_count(database->con) < 2)
|
||||
{
|
||||
mysql_free_result(result);
|
||||
skygw_log_write(LE,"Error: Malformed result for \"SHOW STATUS LIKE 'Ndb_number_of_ready_data_nodes'\"");
|
||||
return;
|
||||
}
|
||||
|
||||
while ((row = mysql_fetch_row(result)))
|
||||
{
|
||||
if (atoi(row[1]) > 0)
|
||||
@ -335,6 +342,13 @@ char *server_string;
|
||||
if (mysql_query(database->con, "SHOW STATUS LIKE 'Ndb_cluster_node_id'") == 0
|
||||
&& (result = mysql_store_result(database->con)) != NULL)
|
||||
{
|
||||
if(mysql_field_count(database->con) < 2)
|
||||
{
|
||||
mysql_free_result(result);
|
||||
skygw_log_write(LE,"Error: Malformed result for \"SHOW STATUS LIKE 'Ndb_cluster_node_id'\"");
|
||||
return;
|
||||
}
|
||||
|
||||
long cluster_node_id = -1;
|
||||
while ((row = mysql_fetch_row(result)))
|
||||
{
|
||||
|
Reference in New Issue
Block a user