1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-07 02:42:49 +03:00

Fix for CONC-1 (Inverted error messages no 2058,2059)

Added support for old password authentication:
- Fixed scramble_323:
    use exact length of message (SCRAMBLE_LENGTH_323 instead
    of strlen(message))
- Added old_password_authentication plugin into list of builtin plugins
This commit is contained in:
Georg Richter
2012-12-15 08:23:43 +01:00
parent 597bff422c
commit 65c44bd33c
6 changed files with 34 additions and 21 deletions

View File

@@ -5,7 +5,7 @@
PROJECT(mariadb-client C) PROJECT(mariadb-client C)
SET(CPACK_PACKAGE_VERSION_MAJOR 1) SET(CPACK_PACKAGE_VERSION_MAJOR 1)
SET(CPACK_PACKAGE_VERSION_MINOR 0) SET(CPACK_PACKAGE_VERSION_MINOR 1)
SET(CPACK_PACKAGE_VERSION_PATCH 0) SET(CPACK_PACKAGE_VERSION_PATCH 0)
# Minimum required version is Cmake 2.6.x # Minimum required version is Cmake 2.6.x

View File

@@ -153,7 +153,6 @@ enum enum_server_command
#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30) #define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
#define CLIENT_SUPPORTED_FLAGS (CLIENT_LONG_PASSWORD | \ #define CLIENT_SUPPORTED_FLAGS (CLIENT_LONG_PASSWORD | \
CLIENT_LONG_PASSWORD |\
CLIENT_FOUND_ROWS |\ CLIENT_FOUND_ROWS |\
CLIENT_LONG_FLAG |\ CLIENT_LONG_FLAG |\
CLIENT_CONNECT_WITH_DB |\ CLIENT_CONNECT_WITH_DB |\

View File

@@ -138,8 +138,8 @@ const char *client_errors[]=
/* 2055 */ "", /* 2055 */ "",
/* 2056 */ "", /* 2056 */ "",
/* 2057 */ "The number of parameters in bound buffers differs from number of columns in resultset", /* 2057 */ "The number of parameters in bound buffers differs from number of columns in resultset",
/* 2058 */ "Can't connect twice. Already connected", /* 2058 */ "Plugin %s could not be loaded: %s",
/* 2059 */ "Plugin %s could not be loaded: %s", /* 2059 */ "Can't connect twice. Already connected",
"" ""
}; };
#endif #endif

View File

@@ -48,6 +48,7 @@ static auth_plugin_t old_password_client_plugin=
struct st_mysql_client_plugin *mysql_client_builtins[]= struct st_mysql_client_plugin *mysql_client_builtins[]=
{ {
(struct st_mysql_client_plugin *)&old_password_client_plugin,
(struct st_mysql_client_plugin *)&native_password_client_plugin, (struct st_mysql_client_plugin *)&native_password_client_plugin,
0 0
}; };

View File

@@ -179,31 +179,30 @@ void make_password_from_salt(char *to, ulong *hash_res)
* Genererate a new message based on message and password * Genererate a new message based on message and password
* The same thing is done in client and server and the results are checked. * The same thing is done in client and server and the results are checked.
*/ */
char *scramble_323(char *to, const char *message, const char *password)
char *scramble_323(char *to,const char *message,const char *password)
{ {
struct rand_struct rand_st; struct rand_struct rand_st;
ulong hash_pass[2],hash_message[2]; ulong hash_pass[2], hash_message[2];
if (password && password[0]) if (password && password[0])
{ {
char *to_start=to; char extra, *to_start=to;
hash_password(hash_pass, password, strlen(password)); const char *end_scramble323= message + SCRAMBLE_LENGTH_323;
hash_password(hash_message, message, strlen(message)); hash_password(hash_pass,password, (uint) strlen(password));
randominit(&rand_st,hash_pass[0] ^ hash_message[0], /* Don't use strlen, could be > SCRAMBLE_LENGTH_323 ! */
hash_pass[1] ^ hash_message[1]); hash_password(hash_message, message, SCRAMBLE_LENGTH_323);
while (*message++) randominit(&rand_st, hash_pass[0] ^ hash_message[0],
*to++= (char) (floor(rnd(&rand_st)*31)+64); hash_pass[1] ^ hash_message[1]);
{ /* Make it harder to break */ for (; message < end_scramble323; message++)
char extra=(char) (floor(rnd(&rand_st)*31)); *to++= (char) (floor(rnd(&rand_st) * 31) + 64);
while (to_start != to) extra=(char) (floor(rnd(&rand_st) * 31));
*(to_start++)^=extra; while (to_start != to)
} *(to_start++)^= extra;
} }
*to=0; *to= 0;
return to; return to;
} }
my_bool check_scramble(const char *scrambled, const char *message, my_bool check_scramble(const char *scrambled, const char *message,
ulong *hash_pass, my_bool old_ver) ulong *hash_pass, my_bool old_ver)
{ {

View File

@@ -424,6 +424,19 @@ static int test_status(MYSQL *mysql)
return OK; return OK;
} }
static int bug_conc1(MYSQL *mysql)
{
mysql_real_connect(mysql, hostname, username, password, schema,
port, socketname, 0);
FAIL_IF(mysql_errno(mysql) != CR_ALREADY_CONNECTED,
"Expected errno=CR_ALREADY_CONNECTED");
FAIL_IF(strcmp(mysql_error(mysql), ER(CR_ALREADY_CONNECTED)) != 0,
"Wrong error message");
FAIL_IF(strcmp(ER(CR_ALREADY_CONNECTED), "Can't connect twice. Already connected") != 0,
"wrong error message");
return OK;
}
struct my_tests_st my_tests[] = { struct my_tests_st my_tests[] = {
{"basic_connect", basic_connect, TEST_CONNECTION_NONE, 0, NULL, NULL}, {"basic_connect", basic_connect, TEST_CONNECTION_NONE, 0, NULL, NULL},
{"use_utf8", use_utf8, TEST_CONNECTION_NEW, 0, opt_utf8, NULL}, {"use_utf8", use_utf8, TEST_CONNECTION_NEW, 0, opt_utf8, NULL},
@@ -433,6 +446,7 @@ struct my_tests_st my_tests[] = {
{"test_mysql_insert_id", test_mysql_insert_id, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_mysql_insert_id", test_mysql_insert_id, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_bug12001", test_bug12001, TEST_CONNECTION_NEW, CLIENT_MULTI_STATEMENTS, NULL, NULL}, {"test_bug12001", test_bug12001, TEST_CONNECTION_NEW, CLIENT_MULTI_STATEMENTS, NULL, NULL},
{"test_status", test_status, TEST_CONNECTION_NEW, CLIENT_MULTI_STATEMENTS, NULL, NULL}, {"test_status", test_status, TEST_CONNECTION_NEW, CLIENT_MULTI_STATEMENTS, NULL, NULL},
{"bug_conc1", bug_conc1, TEST_CONNECTION_NEW, 0, NULL, NULL},
{NULL, NULL, 0, 0, NULL, NULL} {NULL, NULL, 0, 0, NULL, NULL}
}; };