From d72dbb41229ceb6434ecd3e23d559bb7b39dd15f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 20 Feb 2017 22:40:47 +0100 Subject: bugfix: remove my_delete_with_symlink() it was race condition prone. instead use either a pair of my_delete() calls with already resolved paths, or a safe high-level function my_handler_delete_with_symlink(), like MyISAM and Aria already do. --- sql/handler.cc | 4 +--- sql/sql_db.cc | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'sql') diff --git a/sql/handler.cc b/sql/handler.cc index cef3f098161..2ae144a86cc 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3378,12 +3378,10 @@ int handler::delete_table(const char *name) int saved_error= 0; int error= 0; int enoent_or_zero= ENOENT; // Error if no file was deleted - char buff[FN_REFLEN]; for (const char **ext=bas_ext(); *ext ; ext++) { - fn_format(buff, name, "", *ext, MY_UNPACK_FILENAME|MY_APPEND_EXT); - if (mysql_file_delete_with_symlink(key_file_misc, buff, MYF(0))) + if (my_handler_delete_with_symlink(key_file_misc, name, *ext, 0)) { if (my_errno != ENOENT) { diff --git a/sql/sql_db.cc b/sql/sql_db.cc index f72a8918f61..7bb4f0fa60e 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -1083,9 +1083,9 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp, strxmov(filePath, path, "/", file->name, NullS); /* We ignore ENOENT error in order to skip files that was deleted - by concurrently running statement like REAPIR TABLE ... + by concurrently running statement like REPAIR TABLE ... */ - if (my_delete_with_symlink(filePath, MYF(0)) && + if (my_handler_delete_with_symlink(key_file_misc, filePath, "", MYF(0)) && my_errno != ENOENT) { my_error(EE_DELETE, MYF(0), filePath, my_errno); @@ -1206,7 +1206,7 @@ long mysql_rm_arc_files(THD *thd, MY_DIR *dirp, const char *org_path) continue; } strxmov(filePath, org_path, "/", file->name, NullS); - if (mysql_file_delete_with_symlink(key_file_misc, filePath, MYF(MY_WME))) + if (my_handler_delete_with_symlink(key_file_misc, filePath, "", MYF(MY_WME))) { goto err; } -- cgit v1.2.1