Added missing checks for proper column count on query result.
This commit is contained in:
Markus Makela
2015-06-28 08:43:05 +03:00
parent 05991384a6
commit 113fb4c33b
4 changed files with 84 additions and 3 deletions

View File

@ -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*/