From 75f0f1708bb2671f672e8a7de9ec907b45809611 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 6 Aug 2014 14:02:05 +0200 Subject: [PATCH] MDEV-6543 Crash if enable 'federatedx' when 'federated' plugin already enabled, and vice-versa INSTALL SONAME ignores attempts to load the same plugin twice, it's not an error (because one can load one plugin by name and then install soname for the rest). But Federated and FederatedX are different plugins, despite having the same name. Now plugin_add() only considers two plugins identical if their names are the same string (compared as pointers). Otherwise it reports an error., --- .../suite/plugins/r/false_dupes-6543.result | 5 +++++ .../suite/plugins/t/false_dupes-6543.test | 18 ++++++++++++++++++ sql/sql_plugin.cc | 10 ++++++++-- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 mysql-test/suite/plugins/r/false_dupes-6543.result create mode 100644 mysql-test/suite/plugins/t/false_dupes-6543.test diff --git a/mysql-test/suite/plugins/r/false_dupes-6543.result b/mysql-test/suite/plugins/r/false_dupes-6543.result new file mode 100644 index 00000000000..22accaaae8a --- /dev/null +++ b/mysql-test/suite/plugins/r/false_dupes-6543.result @@ -0,0 +1,5 @@ +install soname 'ha_federated'; +install soname 'ha_federated'; +install soname 'ha_federatedx'; +ERROR HY000: Function 'FEDERATED' already exists +uninstall soname 'ha_federated'; diff --git a/mysql-test/suite/plugins/t/false_dupes-6543.test b/mysql-test/suite/plugins/t/false_dupes-6543.test new file mode 100644 index 00000000000..ebdbe00e47c --- /dev/null +++ b/mysql-test/suite/plugins/t/false_dupes-6543.test @@ -0,0 +1,18 @@ +# +# MDEV-6543 Crash if enable 'federatedx' when 'federated' plugin already enabled, and vice-versa +# +if(!$HA_FEDERATED_SO) { + skip Needs ha_federated.so; +} +if(!$HA_FEDERATEDX_SO) { + skip Needs ha_federatedx.so; +} + +install soname 'ha_federated'; +# note: no error below! install soname ignores already loaded plugins +install soname 'ha_federated'; +# note: an error here, even though plugin name is the same! +--error ER_UDF_EXISTS +install soname 'ha_federatedx'; +uninstall soname 'ha_federated'; + diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index c2ab07acd1a..d79cc0aaada 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1040,7 +1040,7 @@ static st_plugin_int *plugin_insert_or_reuse(struct st_plugin_int *plugin) static bool plugin_add(MEM_ROOT *tmp_root, const LEX_STRING *name, LEX_STRING *dl, int report) { - struct st_plugin_int tmp; + struct st_plugin_int tmp, *maybe_dupe; struct st_maria_plugin *plugin; uint oks= 0, errs= 0, dupes= 0; DBUG_ENTER("plugin_add"); @@ -1070,8 +1070,14 @@ static bool plugin_add(MEM_ROOT *tmp_root, (const uchar *)tmp.name.str, tmp.name.length)) continue; // plugin name doesn't match - if (!name->str && plugin_find_internal(&tmp.name, MYSQL_ANY_PLUGIN)) + if (!name->str && + (maybe_dupe= plugin_find_internal(&tmp.name, MYSQL_ANY_PLUGIN))) { + if (plugin->name != maybe_dupe->plugin->name) + { + report_error(report, ER_UDF_EXISTS, plugin->name); + DBUG_RETURN(TRUE); + } dupes++; continue; // already installed }