@@ -405,6 +405,7 @@ struct st_mysql_client_plugin *mysql_load_plugin_v(MYSQL *mysql,
405405 void *sym, *dlhandle;
406406 struct st_mysql_client_plugin *plugin;
407407 const char *plugindir;
408+ const CHARSET_INFO *cs = nullptr ;
408409 size_t len = (name ? strlen (name) : 0 );
409410 int well_formed_error;
410411 size_t res = 0 ;
@@ -435,15 +436,18 @@ struct st_mysql_client_plugin *mysql_load_plugin_v(MYSQL *mysql,
435436 plugindir = PLUGINDIR;
436437 }
437438 }
439+ if (mysql && mysql->charset )
440+ cs = mysql->charset ;
441+ else
442+ cs = &my_charset_utf8mb4_bin;
438443 /* check if plugin name does not have any directory separator character */
439- if ((my_strcspn (mysql->charset , name, name + len, FN_DIRSEP,
440- strlen (FN_DIRSEP))) < len) {
444+ if ((my_strcspn (cs, name, name + len, FN_DIRSEP, strlen (FN_DIRSEP))) < len) {
441445 errmsg = " No paths allowed for shared library" ;
442446 goto err;
443447 }
444448 /* check if plugin name does not exceed its maximum length */
445- res = mysql-> charset -> cset ->well_formed_len (
446- mysql-> charset , name, name + len, NAME_CHAR_LEN, &well_formed_error);
449+ res = cs-> cset ->well_formed_len (cs, name, name + len, NAME_CHAR_LEN,
450+ &well_formed_error);
447451
448452 if (well_formed_error || len != res) {
449453 errmsg = " Invalid plugin name" ;
@@ -453,7 +457,7 @@ struct st_mysql_client_plugin *mysql_load_plugin_v(MYSQL *mysql,
453457 check if length of(plugin_dir + plugin name) does not exceed its maximum
454458 length
455459 */
456- if (strlen (plugindir) + len + 1 >= FN_REFLEN) {
460+ if (( strlen (plugindir) + len + 1 ) >= FN_REFLEN) {
457461 errmsg = " Invalid path" ;
458462 goto err;
459463 }
0 commit comments