@@ -6352,7 +6352,7 @@ const char fmt_gtid_pos[]= "%sSET GLOBAL gtid_slave_pos='%s';\n";
63526352
63536353static int do_show_master_status (MYSQL *mysql_con, int consistent_binlog_pos,
63546354 int have_mariadb_gtid, int use_gtid,
6355- char *set_gtid_pos)
6355+ char *set_gtid_pos, size_t set_gtid_pos_size )
63566356{
63576357 MYSQL_ROW row;
63586358 MYSQL_RES *UNINIT_VAR (master);
@@ -6427,7 +6427,7 @@ static int do_show_master_status(MYSQL *mysql_con, int consistent_binlog_pos,
64276427 " CHANGE-MASTER settings to the slave gtid state is printed "
64286428 " later in the file.\n " );
64296429 }
6430- sprintf (set_gtid_pos, fmt_gtid_pos,
6430+ snprintf (set_gtid_pos, set_gtid_pos_size , fmt_gtid_pos,
64316431 (!use_gtid ? " -- " : comment_prefix), gtid_pos);
64326432 }
64336433
@@ -6479,7 +6479,7 @@ static int do_stop_slave_sql(MYSQL *mysql_con)
64796479 {
64806480 char query[160 ];
64816481 if (multi_source)
6482- sprintf (query, " STOP SLAVE '%.80s' SQL_THREAD" , row[0 ]);
6482+ snprintf (query, sizeof (query) , " STOP SLAVE '%.80s' SQL_THREAD" , row[0 ]);
64836483 else
64846484 strmov (query, " STOP SLAVE SQL_THREAD" );
64856485
@@ -6518,7 +6518,8 @@ static int add_slave_statements(void)
65186518}
65196519
65206520static int do_show_slave_status (MYSQL *mysql_con, int have_mariadb_gtid,
6521- int use_gtid, char * set_gtid_pos)
6521+ int use_gtid, char * set_gtid_pos,
6522+ size_t set_gtid_pos_size)
65226523{
65236524 MYSQL_RES *UNINIT_VAR (slave);
65246525 MYSQL_ROW row;
@@ -6563,7 +6564,8 @@ static int do_show_slave_status(MYSQL *mysql_con, int have_mariadb_gtid,
65636564 " \n -- A corresponding to the below dump-slave "
65646565 " CHANGE-MASTER settings to the slave gtid state is printed "
65656566 " later in the file.\n " );
6566- sprintf (set_gtid_pos, fmt_gtid_pos, gtid_comment_prefix, gtid_pos);
6567+ snprintf (set_gtid_pos, set_gtid_pos_size,
6568+ fmt_gtid_pos, gtid_comment_prefix, gtid_pos);
65676569 }
65686570 if (use_gtid)
65696571 print_comment (md_result_file, 0 ,
@@ -6639,7 +6641,8 @@ static int do_start_slave_sql(MYSQL *mysql_con)
66396641 {
66406642 char query[160 ];
66416643 if (multi_source)
6642- sprintf (query, " START SLAVE '%.80s' SQL_THREAD" , row[0 ]);
6644+ snprintf (query, sizeof (query),
6645+ " START SLAVE '%.80s' SQL_THREAD" , row[0 ]);
66436646 else
66446647 strmov (query, " START SLAVE SQL_THREAD" );
66456648
@@ -7738,11 +7741,13 @@ int main(int argc, char **argv)
77387741
77397742 if (opt_master_data && do_show_master_status (mysql, consistent_binlog_pos,
77407743 have_mariadb_gtid,
7741- opt_use_gtid, master_set_gtid_pos))
7744+ opt_use_gtid, master_set_gtid_pos,
7745+ sizeof (master_set_gtid_pos)))
77427746 goto err;
77437747 if (opt_slave_data && do_show_slave_status (mysql,
77447748 have_mariadb_gtid,
7745- opt_use_gtid, slave_set_gtid_pos))
7749+ opt_use_gtid, slave_set_gtid_pos,
7750+ sizeof (slave_set_gtid_pos)))
77467751 goto err;
77477752 if (opt_single_transaction && do_unlock_tables (mysql)) /* unlock but no commit! */
77487753 goto err;
0 commit comments