Skip to content

Commit 57f6a1c

Browse files
committed
MDEV-19415: use-after-free on charsets_dir from slave connect
The slave IO thread sets MYSQL_SET_CHARSET_DIR. The code for this option however is not thread-safe in sql-common/client.c. The value set is temporarily written to mysys global variable `charsets-dir` and can be seen by other threads running in parallel, which can result in use-after-free error. Problem was visible as random failures of test cases in suite multi_source with Valgrind or MSAN. Work-around by not setting this option for slave connect, it is redundant anyway as it is just setting the default value. Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
1 parent 0c249ad commit 57f6a1c

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

sql/slave.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7412,9 +7412,6 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi,
74127412
default_client_charset_info->csname);
74137413
}
74147414

7415-
/* This one is not strictly needed but we have it here for completeness */
7416-
mysql_options(mysql, MYSQL_SET_CHARSET_DIR, (char *) charsets_dir);
7417-
74187415
/* Set MYSQL_PLUGIN_DIR in case master asks for an external authentication plugin */
74197416
if (opt_plugin_dir_ptr && *opt_plugin_dir_ptr)
74207417
mysql_options(mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir_ptr);
@@ -7557,8 +7554,6 @@ MYSQL *rpl_connect_master(MYSQL *mysql)
75577554
#endif
75587555

75597556
mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset_info->csname);
7560-
/* This one is not strictly needed but we have it here for completeness */
7561-
mysql_options(mysql, MYSQL_SET_CHARSET_DIR, (char *) charsets_dir);
75627557

75637558
if (mi->user == NULL
75647559
|| mi->user[0] == 0

0 commit comments

Comments
 (0)