Skip to content

Commit d422be6

Browse files
author
Bharathy Satish
committed
Merge branch 'mysql-5.6' into mysql-5.7
2 parents bb25221 + 074882f commit d422be6

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

sql-common/client_plugin.c

+30-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -437,6 +437,10 @@ mysql_load_plugin_v(MYSQL *mysql, const char *name, int type,
437437
void *sym, *dlhandle;
438438
struct st_mysql_client_plugin *plugin;
439439
const char *plugindir;
440+
const CHARSET_INFO *cs = NULL;
441+
size_t len = (name ? strlen(name) : 0);
442+
int well_formed_error;
443+
size_t res = 0;
440444
#ifdef _WIN32
441445
char win_errormsg[2048];
442446
#endif
@@ -470,6 +474,31 @@ mysql_load_plugin_v(MYSQL *mysql, const char *name, int type,
470474
plugindir= PLUGINDIR;
471475
}
472476
}
477+
if (mysql && mysql->charset)
478+
cs = mysql->charset;
479+
else
480+
cs = &my_charset_latin1;
481+
/* check if plugin name does not have any directory separator character */
482+
if ((my_strcspn(cs, name, name + len, FN_DIRSEP, strlen(FN_DIRSEP))) < len) {
483+
errmsg = "No paths allowed for shared library";
484+
goto err;
485+
}
486+
/* check if plugin name does not exceed its maximum length */
487+
res = cs->cset->well_formed_len(cs, name, name + len, NAME_CHAR_LEN,
488+
&well_formed_error);
489+
490+
if (well_formed_error || len != res) {
491+
errmsg = "Invalid plugin name";
492+
goto err;
493+
}
494+
/*
495+
check if length of(plugin_dir + plugin name) does not exceed its maximum
496+
length
497+
*/
498+
if ((strlen(plugindir) + len + 1) >= FN_REFLEN) {
499+
errmsg = "Invalid path";
500+
goto err;
501+
}
473502

474503
/* Compile dll path */
475504
strxnmov(dlpath, sizeof(dlpath) - 1,

sql/auth/sql_authentication.cc

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -659,11 +659,18 @@ static bool send_plugin_request_packet(MPVIO_EXT *mpvio,
659659
DBUG_ENTER("send_plugin_request_packet");
660660
mpvio->status= MPVIO_EXT::FAILURE; // the status is no longer RESTART
661661

662-
const char *client_auth_plugin=
663-
((st_mysql_auth *) (plugin_decl(mpvio->plugin)->info))->client_auth_plugin;
662+
std::string client_auth_plugin(
663+
((st_mysql_auth *)(plugin_decl(mpvio->plugin)->info))
664+
->client_auth_plugin);
664665

665-
DBUG_ASSERT(client_auth_plugin);
666+
DBUG_ASSERT(client_auth_plugin.c_str());
666667

668+
DBUG_EXECUTE_IF("invalidate_client_auth_plugin", {
669+
client_auth_plugin.clear();
670+
client_auth_plugin = std::string("..") + std::string(FN_DIRSEP) +
671+
std::string("..") + std::string(FN_DIRSEP) +
672+
std::string("mysql_native_password");
673+
});
667674
/*
668675
If we're dealing with an older client we can't just send a change plugin
669676
packet to re-initiate the authentication handshake, because the client
@@ -683,11 +690,11 @@ static bool send_plugin_request_packet(MPVIO_EXT *mpvio,
683690
}
684691

685692
DBUG_PRINT("info", ("requesting client to use the %s plugin",
686-
client_auth_plugin));
693+
client_auth_plugin.c_str()));
687694
DBUG_RETURN(net_write_command(mpvio->protocol->get_net(),
688695
switch_plugin_request_buf[0],
689-
(uchar*) client_auth_plugin,
690-
strlen(client_auth_plugin) + 1,
696+
(uchar*) client_auth_plugin.c_str(),
697+
client_auth_plugin.size() + 1,
691698
(uchar*) data, data_len));
692699
}
693700

0 commit comments

Comments
 (0)