Skip to content

Commit ca23b48

Browse files
author
V S Murthy Sidagam
committed
Bug#35054579 Issue in Oracle MySQL Client using utf16 charset
Description: If we try to connect the server with mysql client using --default-character-set=utf1 using a authentication plugin, the client connection is failing with below error ERROR 2059 (HY000): Authentication plugin '../../mysql_native_password' cannot be loaded: '../../mysql_native_password.so': cannot open shared object file: No such file or directory instead of ERROR 2059 (HY000): Authentication plugin '../../mysql_native_password' cannot be loaded: No paths allowed for shared library Analysis: As per mysql documentation utf16, utf32, ucs2 and utf16le are Impermissible Client Character Sets, so when the client tries to connect the server with these charsets, the client has to reject the connections. Fix: While parsing the mysq client options, detecting the Impermissible Client Character Sets and rejecting the connection. Change-Id: Ib0d6624c792214b7b44fbb7040646f04081fb3e0
1 parent f72f36f commit ca23b48

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

client/mysql.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4731,7 +4731,7 @@ static bool init_connection_options(MYSQL *mysql) {
47314731
mysql_options(mysql, MYSQL_INIT_COMMAND, init_command);
47324732
}
47334733

4734-
mysql_set_character_set(mysql, default_charset);
4734+
if (mysql_set_character_set(mysql, default_charset)) return true;
47354735

47364736
if (opt_plugin_dir && *opt_plugin_dir)
47374737
mysql_options(mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir);

include/errmsg.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ extern const char *client_errors[]; /* Error messages */
132132
#define CR_MANDATORY_TRACKER_NOT_FOUND 2071
133133
#define CR_INVALID_FACTOR_NO 2072
134134
#define CR_CANT_GET_SESSION_DATA 2073
135-
#define CR_ERROR_LAST /*Copy last error nr:*/ 2073
135+
#define CR_INVALID_CLIENT_CHARSET 2074
136+
#define CR_ERROR_LAST /*Copy last error nr:*/ 2074
136137
/* Add error numbers before CR_ERROR_LAST and change it accordingly. */
137138

138139
/* Visual Studio requires '__inline' for C code */

include/mysql.h.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@
364364
void finish_client_errs(void);
365365
extern const char *client_errors[];
366366
static inline const char *ER_CLIENT(int client_errno) {
367-
if (client_errno >= 2000 && client_errno <= 2073)
367+
if (client_errno >= 2000 && client_errno <= 2074)
368368
return client_errors[client_errno - 2000];
369369
return client_errors[2000 - 2000];
370370
}

libmysql/errmsg.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ const char *client_errors[] = {
119119
"Invalid first argument for MYSQL_OPT_USER_PASSWORD option. Valid value "
120120
"should be between 1 and 3 inclusive.",
121121
"Can't get session data: %s",
122+
"'%-.32s' character set is having more than 1 byte minimum character "
123+
"length, which cannot be used as a client character set. Please use any "
124+
"of the single byte minimum ones, e.g. utf8mb4, latin1 etc.",
122125
""};
123126

124127
static const char *get_client_errmsg(int nr) {

sql-common/client.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9211,6 +9211,17 @@ int STDCALL mysql_set_character_set(MYSQL *mysql, const char *cs_name) {
92119211
cs_name = mysql->options.charset_name;
92129212
}
92139213

9214+
#ifndef MYSQL_SERVER
9215+
if (mysql->charset != nullptr) {
9216+
if (!is_supported_parser_charset(mysql->charset)) {
9217+
set_mysql_extended_error(mysql, CR_INVALID_CLIENT_CHARSET,
9218+
unknown_sqlstate,
9219+
ER_CLIENT(CR_INVALID_CLIENT_CHARSET), cs_name);
9220+
return 1;
9221+
}
9222+
}
9223+
#endif
9224+
92149225
if (strlen(cs_name) < MY_CS_NAME_SIZE &&
92159226
(cs = get_charset_by_csname(cs_name, MY_CS_PRIMARY, MYF(0)))) {
92169227
char buff[MY_CS_NAME_SIZE + 10];

0 commit comments

Comments
 (0)