You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +03:00
10.2 integration fixes:
- renamed/prefixed password functions - prepared statement fixes for mysql_client_test
This commit is contained in:
@@ -32,7 +32,7 @@ ENDIF()
|
|||||||
|
|
||||||
# AUTHENTICATION
|
# AUTHENTICATION
|
||||||
REGISTER_PLUGIN("AUTH_NATIVE" "${CMAKE_SOURCE_DIR}/plugins/auth/my_auth.c" "native_password_client_plugin" "STATIC" "" 0)
|
REGISTER_PLUGIN("AUTH_NATIVE" "${CMAKE_SOURCE_DIR}/plugins/auth/my_auth.c" "native_password_client_plugin" "STATIC" "" 0)
|
||||||
REGISTER_PLUGIN("AUTH_OLDPASSWORD" "${CMAKE_SOURCE_DIR}/plugins/auth/old_password.c" "old_password_client_plugin" "DYNAMIC" "old_password" 1)
|
REGISTER_PLUGIN("AUTH_OLDPASSWORD" "${CMAKE_SOURCE_DIR}/plugins/auth/old_password.c" "old_password_client_plugin" "DYNAMIC" "mysql_old_password" 1)
|
||||||
REGISTER_PLUGIN("AUTH_DIALOG" "${CMAKE_SOURCE_DIR}/plugins/auth/dialog.c" "auth_dialog_plugin" "DYNAMIC" dialog 1)
|
REGISTER_PLUGIN("AUTH_DIALOG" "${CMAKE_SOURCE_DIR}/plugins/auth/dialog.c" "auth_dialog_plugin" "DYNAMIC" dialog 1)
|
||||||
REGISTER_PLUGIN("AUTH_CLEARTEXT" "${CMAKE_SOURCE_DIR}/plugins/auth/mariadb_clear_text.c" "auth_cleartext_plugin" "DYNAMIC" "mysql_clear_password" 1)
|
REGISTER_PLUGIN("AUTH_CLEARTEXT" "${CMAKE_SOURCE_DIR}/plugins/auth/mariadb_clear_text.c" "auth_cleartext_plugin" "DYNAMIC" "mysql_clear_password" 1)
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
|
@@ -275,5 +275,5 @@
|
|||||||
#cmakedefine HAVE_THREADS 1
|
#cmakedefine HAVE_THREADS 1
|
||||||
#cmakedefine SHAREDIR "@SHAREDIR@"
|
#cmakedefine SHAREDIR "@SHAREDIR@"
|
||||||
#cmakedefine DEFAULT_CHARSET_HOME "@DEFAULT_CHARSET_HOME@"
|
#cmakedefine DEFAULT_CHARSET_HOME "@DEFAULT_CHARSET_HOME@"
|
||||||
#cmakedefine PLUGINDIR "@PREFIX_INSTALL_DIR@/@PLUGIN_INSTALL_DIR@"
|
#cmakedefine MARIADB_PLUGINDIR "@PREFIX_INSTALL_DIR@/@PLUGIN_INSTALL_DIR@"
|
||||||
|
|
||||||
|
@@ -412,17 +412,10 @@ typedef struct st_udf_init
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void randominit(struct rand_struct *,unsigned long seed1,
|
char *ma_scramble_323(char *to,const char *message,const char *password);
|
||||||
unsigned long seed2);
|
void ma_scramble_41(const unsigned char *buffer, const char *scramble, const char *password);
|
||||||
double rnd(struct rand_struct *);
|
void ma_hash_password(unsigned long *result, const char *password, size_t len);
|
||||||
void make_scrambled_password(char *to,const char *password);
|
void ma_make_scrambled_password(char *to,const char *password);
|
||||||
void get_salt_from_password(unsigned long *res,const char *password);
|
|
||||||
void make_password_from_salt(char *to, unsigned long *hash_res);
|
|
||||||
char *scramble_323(char *to,const char *message,const char *password);
|
|
||||||
void my_scramble_41(const unsigned char *buffer, const char *scramble, const char *password);
|
|
||||||
my_bool check_scramble(const char *, const char *message,
|
|
||||||
unsigned long *salt,my_bool old_ver);
|
|
||||||
void hash_password(unsigned long *result, const char *password, size_t len);
|
|
||||||
|
|
||||||
/* Some other useful functions */
|
/* Some other useful functions */
|
||||||
|
|
||||||
|
@@ -281,6 +281,7 @@ extern unsigned int mariadb_deinitialize_ssl;
|
|||||||
MYSQL_STATUS_FETCHING_DATA,
|
MYSQL_STATUS_FETCHING_DATA,
|
||||||
MYSQL_STATUS_NEXT_RESULT_PENDING,
|
MYSQL_STATUS_NEXT_RESULT_PENDING,
|
||||||
MYSQL_STATUS_QUIT_SENT, /* object is "destroyed" at this stage */
|
MYSQL_STATUS_QUIT_SENT, /* object is "destroyed" at this stage */
|
||||||
|
MYSQL_STATUS_STMT_RESULT
|
||||||
};
|
};
|
||||||
|
|
||||||
enum mysql_protocol_type
|
enum mysql_protocol_type
|
||||||
@@ -580,7 +581,7 @@ int STDCALL mysql_rollback_start(my_bool *ret, MYSQL * mysql);
|
|||||||
int STDCALL mysql_rollback_cont(my_bool *ret, MYSQL * mysql, int status);
|
int STDCALL mysql_rollback_cont(my_bool *ret, MYSQL * mysql, int status);
|
||||||
int STDCALL mysql_autocommit_start(my_bool *ret, MYSQL * mysql,
|
int STDCALL mysql_autocommit_start(my_bool *ret, MYSQL * mysql,
|
||||||
my_bool auto_mode);
|
my_bool auto_mode);
|
||||||
int STDCALL mysql_list_fields_cont(MYSQL_RES **ret, MYSQL *mysql, int status);
|
int STDCALL mysql_list_fields_cont(MYSQL_RES **ret, MYSQL *mysql, int ready_status);
|
||||||
int STDCALL mysql_list_fields_start(MYSQL_RES **ret, MYSQL *mysql, const char *table,
|
int STDCALL mysql_list_fields_start(MYSQL_RES **ret, MYSQL *mysql, const char *table,
|
||||||
const char *wild);
|
const char *wild);
|
||||||
int STDCALL mysql_autocommit_cont(my_bool *ret, MYSQL * mysql, int status);
|
int STDCALL mysql_autocommit_cont(my_bool *ret, MYSQL * mysql, int status);
|
||||||
|
@@ -375,6 +375,7 @@ mysql_load_plugin_v(MYSQL *mysql, const char *name, int type,
|
|||||||
struct st_mysql_client_plugin *plugin;
|
struct st_mysql_client_plugin *plugin;
|
||||||
char *env_plugin_dir= getenv("MARIADB_PLUGIN_DIR");
|
char *env_plugin_dir= getenv("MARIADB_PLUGIN_DIR");
|
||||||
|
|
||||||
|
CLEAR_CLIENT_ERROR(mysql);
|
||||||
if (is_not_initialized(mysql, name))
|
if (is_not_initialized(mysql, name))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -391,7 +392,7 @@ mysql_load_plugin_v(MYSQL *mysql, const char *name, int type,
|
|||||||
snprintf(dlpath, sizeof(dlpath) - 1, "%s/%s%s",
|
snprintf(dlpath, sizeof(dlpath) - 1, "%s/%s%s",
|
||||||
mysql->options.extension && mysql->options.extension->plugin_dir ?
|
mysql->options.extension && mysql->options.extension->plugin_dir ?
|
||||||
mysql->options.extension->plugin_dir : (env_plugin_dir) ? env_plugin_dir :
|
mysql->options.extension->plugin_dir : (env_plugin_dir) ? env_plugin_dir :
|
||||||
PLUGINDIR, name, SO_EXT);
|
MARIADB_PLUGINDIR, name, SO_EXT);
|
||||||
|
|
||||||
/* Open new dll handle */
|
/* Open new dll handle */
|
||||||
if (!(dlhandle= dlopen((const char *)dlpath, RTLD_NOW)))
|
if (!(dlhandle= dlopen((const char *)dlpath, RTLD_NOW)))
|
||||||
@@ -486,4 +487,3 @@ mysql_client_find_plugin(MYSQL *mysql, const char *name, int type)
|
|||||||
return mysql_load_plugin(mysql, name, type, 0);
|
return mysql_load_plugin(mysql, name, type, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -105,7 +105,6 @@ int ma_net_init(NET *net, MARIADB_PVIO* pvio)
|
|||||||
|
|
||||||
/* We don't allocate memory for multi buffer, since we don't know in advance if the server
|
/* We don't allocate memory for multi buffer, since we don't know in advance if the server
|
||||||
* supports COM_MULTI comand. It will be allocated on demand in net_add_multi_command */
|
* supports COM_MULTI comand. It will be allocated on demand in net_add_multi_command */
|
||||||
|
|
||||||
max_allowed_packet= net->max_packet_size= MAX(net_buffer_length, max_allowed_packet);
|
max_allowed_packet= net->max_packet_size= MAX(net_buffer_length, max_allowed_packet);
|
||||||
net->buff_end=net->buff+(net->max_packet=net_buffer_length);
|
net->buff_end=net->buff+(net->max_packet=net_buffer_length);
|
||||||
net->pvio = pvio;
|
net->pvio = pvio;
|
||||||
|
@@ -43,7 +43,7 @@
|
|||||||
#include "mysql.h"
|
#include "mysql.h"
|
||||||
|
|
||||||
|
|
||||||
void randominit(struct rand_struct *rand_st,ulong seed1, ulong seed2)
|
void ma_randominit(struct rand_struct *rand_st,ulong seed1, ulong seed2)
|
||||||
{ /* For mysql 3.21.# */
|
{ /* For mysql 3.21.# */
|
||||||
#ifdef HAVE_purify
|
#ifdef HAVE_purify
|
||||||
memset((char*) rand_st, 0m sizeof(*rand_st)); /* Avoid UMC varnings */
|
memset((char*) rand_st, 0m sizeof(*rand_st)); /* Avoid UMC varnings */
|
||||||
@@ -54,7 +54,7 @@ void randominit(struct rand_struct *rand_st,ulong seed1, ulong seed2)
|
|||||||
rand_st->seed2=seed2%rand_st->max_value;
|
rand_st->seed2=seed2%rand_st->max_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void old_randominit(struct rand_struct *rand_st,ulong seed1)
|
static void ma_old_randominit(struct rand_struct *rand_st,ulong seed1)
|
||||||
{ /* For mysql 3.20.# */
|
{ /* For mysql 3.20.# */
|
||||||
rand_st->max_value= 0x01FFFFFFL;
|
rand_st->max_value= 0x01FFFFFFL;
|
||||||
rand_st->max_value_dbl=(double) rand_st->max_value;
|
rand_st->max_value_dbl=(double) rand_st->max_value;
|
||||||
@@ -69,7 +69,7 @@ double rnd(struct rand_struct *rand_st)
|
|||||||
return (((double) rand_st->seed1)/rand_st->max_value_dbl);
|
return (((double) rand_st->seed1)/rand_st->max_value_dbl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hash_password(ulong *result, const char *password, size_t len)
|
void ma_hash_password(ulong *result, const char *password, size_t len)
|
||||||
{
|
{
|
||||||
register ulong nr=1345345333L, add=7, nr2=0x12345671L;
|
register ulong nr=1345345333L, add=7, nr2=0x12345671L;
|
||||||
ulong tmp;
|
ulong tmp;
|
||||||
@@ -113,7 +113,7 @@ void my_crypt(unsigned char *buffer, const unsigned char *s1, const unsigned cha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void my_scramble_41(const unsigned char *buffer, const char *scramble, const char *password)
|
void ma_scramble_41(const unsigned char *buffer, const char *scramble, const char *password)
|
||||||
{
|
{
|
||||||
_MA_SHA1_CTX context;
|
_MA_SHA1_CTX context;
|
||||||
unsigned char sha1[SHA1_MAX_LENGTH];
|
unsigned char sha1[SHA1_MAX_LENGTH];
|
||||||
@@ -141,46 +141,18 @@ void my_scramble_41(const unsigned char *buffer, const char *scramble, const cha
|
|||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
void make_scrambled_password(char *to,const char *password)
|
void ma_make_scrambled_password(char *to,const char *password)
|
||||||
{
|
{
|
||||||
ulong hash_res[2];
|
ulong hash_res[2];
|
||||||
hash_password(hash_res,password, strlen(password));
|
ma_hash_password(hash_res,password, strlen(password));
|
||||||
sprintf(to,"%08lx%08lx",hash_res[0],hash_res[1]);
|
sprintf(to,"%08lx%08lx",hash_res[0],hash_res[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
** This code assumes that len(password) is divideable with 8 and that
|
|
||||||
** res is big enough (2 in mysql)
|
|
||||||
*/
|
|
||||||
|
|
||||||
void get_salt_from_password(ulong *res,const char *password)
|
|
||||||
{
|
|
||||||
res[0]=res[1]=0;
|
|
||||||
if (password)
|
|
||||||
{
|
|
||||||
while (*password)
|
|
||||||
{
|
|
||||||
ulong val=0;
|
|
||||||
uint i;
|
|
||||||
for (i=0 ; i < 8 ; i++)
|
|
||||||
val=(val << 4)+char_val(*password++);
|
|
||||||
*res++=val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void make_password_from_salt(char *to, ulong *hash_res)
|
|
||||||
{
|
|
||||||
sprintf(to,"%08lx%08lx",hash_res[0],hash_res[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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 *ma_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];
|
||||||
@@ -189,10 +161,10 @@ char *scramble_323(char *to, const char *message, const char *password)
|
|||||||
{
|
{
|
||||||
char extra, *to_start=to;
|
char extra, *to_start=to;
|
||||||
const char *end_scramble323= message + SCRAMBLE_LENGTH_323;
|
const char *end_scramble323= message + SCRAMBLE_LENGTH_323;
|
||||||
hash_password(hash_pass,password, (uint) strlen(password));
|
ma_hash_password(hash_pass,password, (uint) strlen(password));
|
||||||
/* Don't use strlen, could be > SCRAMBLE_LENGTH_323 ! */
|
/* Don't use strlen, could be > SCRAMBLE_LENGTH_323 ! */
|
||||||
hash_password(hash_message, message, SCRAMBLE_LENGTH_323);
|
ma_hash_password(hash_message, message, SCRAMBLE_LENGTH_323);
|
||||||
randominit(&rand_st, hash_pass[0] ^ hash_message[0],
|
ma_randominit(&rand_st, hash_pass[0] ^ hash_message[0],
|
||||||
hash_pass[1] ^ hash_message[1]);
|
hash_pass[1] ^ hash_message[1]);
|
||||||
for (; message < end_scramble323; message++)
|
for (; message < end_scramble323; message++)
|
||||||
*to++= (char) (floor(rnd(&rand_st) * 31) + 64);
|
*to++= (char) (floor(rnd(&rand_st) * 31) + 64);
|
||||||
@@ -203,33 +175,3 @@ char *scramble_323(char *to, const char *message, const char *password)
|
|||||||
*to= 0;
|
*to= 0;
|
||||||
return to;
|
return to;
|
||||||
}
|
}
|
||||||
|
|
||||||
my_bool check_scramble(const char *scrambled, const char *message,
|
|
||||||
ulong *hash_pass, my_bool old_ver)
|
|
||||||
{
|
|
||||||
struct rand_struct rand_st;
|
|
||||||
ulong hash_message[2];
|
|
||||||
char buff[16],*to,extra; /* Big enough for check */
|
|
||||||
const char *pos;
|
|
||||||
|
|
||||||
hash_password(hash_message,message, strlen(message));
|
|
||||||
if (old_ver)
|
|
||||||
old_randominit(&rand_st,hash_pass[0] ^ hash_message[0]);
|
|
||||||
else
|
|
||||||
randominit(&rand_st,hash_pass[0] ^ hash_message[0],
|
|
||||||
hash_pass[1] ^ hash_message[1]);
|
|
||||||
to=buff;
|
|
||||||
for (pos=scrambled ; *pos ; pos++)
|
|
||||||
*to++=(char) (floor(rnd(&rand_st)*31)+64);
|
|
||||||
if (old_ver)
|
|
||||||
extra=0;
|
|
||||||
else
|
|
||||||
extra=(char) (floor(rnd(&rand_st)*31));
|
|
||||||
to=buff;
|
|
||||||
while (*scrambled)
|
|
||||||
{
|
|
||||||
if (*scrambled++ != (char) (*to++ ^ extra))
|
|
||||||
return 1; /* Wrong password */
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
@@ -126,6 +126,7 @@ static longlong my_atoll(const char *number, const char *end, int *error)
|
|||||||
char buffer[255];
|
char buffer[255];
|
||||||
longlong llval= 0;
|
longlong llval= 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
*error= 0;
|
||||||
/* set error at the following conditions:
|
/* set error at the following conditions:
|
||||||
- string contains invalid character(s)
|
- string contains invalid character(s)
|
||||||
- length > 254
|
- length > 254
|
||||||
@@ -135,6 +136,7 @@ static longlong my_atoll(const char *number, const char *end, int *error)
|
|||||||
memcpy(buffer, number, MIN((uint)(end - number), 254));
|
memcpy(buffer, number, MIN((uint)(end - number), 254));
|
||||||
buffer[(uint)(end - number)]= 0;
|
buffer[(uint)(end - number)]= 0;
|
||||||
|
|
||||||
|
errno= 0;
|
||||||
llval= strtoll(buffer, NULL, 10);
|
llval= strtoll(buffer, NULL, 10);
|
||||||
|
|
||||||
/* check size */
|
/* check size */
|
||||||
@@ -147,7 +149,7 @@ static longlong my_atoll(const char *number, const char *end, int *error)
|
|||||||
/* check characters */
|
/* check characters */
|
||||||
for (i=0; i < strlen(buffer); i++)
|
for (i=0; i < strlen(buffer); i++)
|
||||||
{
|
{
|
||||||
if (buffer[i] < '0' || buffer[i] > '9')
|
if ((buffer[i] < '0' || buffer[i] > '9') && !isspace(buffer[i]))
|
||||||
{
|
{
|
||||||
*error= 1;
|
*error= 1;
|
||||||
return llval;
|
return llval;
|
||||||
@@ -497,7 +499,144 @@ void ma_bmove_upp(register char *dst, register const char *src, register size_t
|
|||||||
while (len-- != 0) *--dst = *--src;
|
while (len-- != 0) *--dst = *--src;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void convert_from_float(MYSQL_BIND *r_param, const MYSQL_FIELD *field, double val, int size)
|
static void convert_from_float(MYSQL_BIND *r_param, const MYSQL_FIELD *field, float val, int size)
|
||||||
|
{
|
||||||
|
double check_trunc_val= (val > 0) ? floor(val) : -floor(-val);
|
||||||
|
char *buf= (char *)r_param->buffer;
|
||||||
|
switch (r_param->buffer_type)
|
||||||
|
{
|
||||||
|
case MYSQL_TYPE_TINY:
|
||||||
|
*buf= (r_param->is_unsigned) ? (uint8)val : (int8)val;
|
||||||
|
*r_param->error= check_trunc_val != (r_param->is_unsigned ? (double)((uint8)*buf) :
|
||||||
|
(double)((int8)*buf));
|
||||||
|
r_param->buffer_length= 1;
|
||||||
|
break;
|
||||||
|
case MYSQL_TYPE_SHORT:
|
||||||
|
case MYSQL_TYPE_YEAR:
|
||||||
|
{
|
||||||
|
if (r_param->is_unsigned)
|
||||||
|
{
|
||||||
|
ushort sval= (ushort)val;
|
||||||
|
shortstore(buf, sval);
|
||||||
|
*r_param->error= check_trunc_val != (double)sval;
|
||||||
|
} else {
|
||||||
|
short sval= (short)val;
|
||||||
|
shortstore(buf, sval);
|
||||||
|
*r_param->error= check_trunc_val != (double)sval;
|
||||||
|
}
|
||||||
|
r_param->buffer_length= 2;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MYSQL_TYPE_LONG:
|
||||||
|
{
|
||||||
|
if (r_param->is_unsigned)
|
||||||
|
{
|
||||||
|
uint32 lval= (uint32)val;
|
||||||
|
longstore(buf, lval);
|
||||||
|
*r_param->error= (check_trunc_val != (double)lval);
|
||||||
|
} else {
|
||||||
|
int32 lval= (int32)val;
|
||||||
|
longstore(buf, lval);
|
||||||
|
*r_param->error= (check_trunc_val != (double)lval);
|
||||||
|
}
|
||||||
|
r_param->buffer_length= 4;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MYSQL_TYPE_LONGLONG:
|
||||||
|
{
|
||||||
|
if (r_param->is_unsigned)
|
||||||
|
{
|
||||||
|
ulonglong llval= (ulonglong)val;
|
||||||
|
longlongstore(buf, llval);
|
||||||
|
*r_param->error= (check_trunc_val != (double)llval);
|
||||||
|
} else {
|
||||||
|
longlong llval= (longlong)val;
|
||||||
|
longlongstore(buf, llval);
|
||||||
|
*r_param->error= (check_trunc_val != (double)llval);
|
||||||
|
}
|
||||||
|
r_param->buffer_length= 8;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MYSQL_TYPE_DOUBLE:
|
||||||
|
{
|
||||||
|
double dval= (double)val;
|
||||||
|
memcpy(buf, &dval, sizeof(double));
|
||||||
|
r_param->buffer_length= 8;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
#define MAX_DOUBLE_STRING_REP_LENGTH 300
|
||||||
|
char buff[MAX_DOUBLE_STRING_REP_LENGTH];
|
||||||
|
size_t length;
|
||||||
|
char *end;
|
||||||
|
|
||||||
|
length= MIN(MAX_DOUBLE_STRING_REP_LENGTH - 1, r_param->buffer_length);
|
||||||
|
|
||||||
|
/* if (field->decimals >= NOT_FIXED_DEC)
|
||||||
|
{
|
||||||
|
sprintf(buff, "%-*.*g", (int) length-1, DBL_DIG, val);
|
||||||
|
length= strlen(buff);
|
||||||
|
}
|
||||||
|
else */
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
_gcvt(val, 6, buff);
|
||||||
|
#else
|
||||||
|
gcvt(val, 6, buff);
|
||||||
|
#endif
|
||||||
|
length= strlen(buff);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* remove trailing blanks */
|
||||||
|
end= strchr(buff, '\0') - 1;
|
||||||
|
while (end > buff && *end == ' ')
|
||||||
|
*end--= '\0';
|
||||||
|
|
||||||
|
/* check if ZEROFILL flag is active */
|
||||||
|
if (field->flags & ZEROFILL_FLAG)
|
||||||
|
{
|
||||||
|
/* enough space available ? */
|
||||||
|
if (field->length < length || field->length > MAX_DOUBLE_STRING_REP_LENGTH - 1)
|
||||||
|
break;
|
||||||
|
ma_bmove_upp(buff + field->length, buff + length, length);
|
||||||
|
memset((char*) buff, 0, field->length - length);
|
||||||
|
}
|
||||||
|
convert_froma_string(r_param, buff, strlen(buff));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* {{{ ps_fetch_float */
|
||||||
|
static
|
||||||
|
void ps_fetch_float(MYSQL_BIND *r_param, const MYSQL_FIELD * field, unsigned char **row)
|
||||||
|
{
|
||||||
|
switch(r_param->buffer_type)
|
||||||
|
{
|
||||||
|
case MYSQL_TYPE_FLOAT:
|
||||||
|
{
|
||||||
|
float *value= (float *)r_param->buffer;
|
||||||
|
float4get(*value, *row);
|
||||||
|
r_param->buffer_length= 4;
|
||||||
|
*r_param->error= 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
float value;
|
||||||
|
memcpy(&value, *row, sizeof(float));
|
||||||
|
float4get(value, (char *)*row);
|
||||||
|
convert_from_float(r_param, field, value, sizeof(float));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
(*row)+= 4;
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
static void convert_from_double(MYSQL_BIND *r_param, const MYSQL_FIELD *field, double val, int size)
|
||||||
{
|
{
|
||||||
double check_trunc_val= (val > 0) ? floor(val) : -floor(-val);
|
double check_trunc_val= (val > 0) ? floor(val) : -floor(-val);
|
||||||
char *buf= (char *)r_param->buffer;
|
char *buf= (char *)r_param->buffer;
|
||||||
@@ -563,12 +702,6 @@ static void convert_from_float(MYSQL_BIND *r_param, const MYSQL_FIELD *field, do
|
|||||||
r_param->buffer_length= 4;
|
r_param->buffer_length= 4;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MYSQL_TYPE_DOUBLE:
|
|
||||||
{
|
|
||||||
memcpy(buf, &val, sizeof(double));
|
|
||||||
r_param->buffer_length= 8;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
#define MAX_DOUBLE_STRING_REP_LENGTH 300
|
#define MAX_DOUBLE_STRING_REP_LENGTH 300
|
||||||
@@ -585,7 +718,11 @@ static void convert_from_float(MYSQL_BIND *r_param, const MYSQL_FIELD *field, do
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(buff, "%.*f", field->decimals, val);
|
#ifdef _WIN32
|
||||||
|
#else
|
||||||
|
gcvt(val, field->decimals, buff);
|
||||||
|
#endif
|
||||||
|
// sprintf(buff, "%.*f", field->decimals, val);
|
||||||
length= strlen(buff);
|
length= strlen(buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -610,34 +747,6 @@ static void convert_from_float(MYSQL_BIND *r_param, const MYSQL_FIELD *field, do
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* {{{ ps_fetch_float */
|
|
||||||
static
|
|
||||||
void ps_fetch_float(MYSQL_BIND *r_param, const MYSQL_FIELD * field, unsigned char **row)
|
|
||||||
{
|
|
||||||
switch(r_param->buffer_type)
|
|
||||||
{
|
|
||||||
case MYSQL_TYPE_FLOAT:
|
|
||||||
{
|
|
||||||
float *value= (float *)r_param->buffer;
|
|
||||||
float4get(*value, *row);
|
|
||||||
r_param->buffer_length= 4;
|
|
||||||
*r_param->error= 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
float value;
|
|
||||||
memcpy(&value, *row, sizeof(float));
|
|
||||||
float4get(value, (char *)*row);
|
|
||||||
convert_from_float(r_param, field, value, sizeof(float));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
(*row)+= 4;
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
|
|
||||||
/* {{{ ps_fetch_double */
|
/* {{{ ps_fetch_double */
|
||||||
static
|
static
|
||||||
void ps_fetch_double(MYSQL_BIND *r_param, const MYSQL_FIELD * field , unsigned char **row)
|
void ps_fetch_double(MYSQL_BIND *r_param, const MYSQL_FIELD * field , unsigned char **row)
|
||||||
@@ -655,7 +764,7 @@ void ps_fetch_double(MYSQL_BIND *r_param, const MYSQL_FIELD * field , unsigned c
|
|||||||
{
|
{
|
||||||
double value;
|
double value;
|
||||||
float8get(value, *row);
|
float8get(value, *row);
|
||||||
convert_from_float(r_param, field, value, sizeof(double));
|
convert_from_double(r_param, field, value, sizeof(double));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -673,7 +782,6 @@ static void convert_to_datetime(MYSQL_TIME *t, unsigned char **row, uint len, en
|
|||||||
7-bytes: DATE + TIME
|
7-bytes: DATE + TIME
|
||||||
>7 bytes: DATE + TIME with second_part
|
>7 bytes: DATE + TIME with second_part
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (len)
|
if (len)
|
||||||
{
|
{
|
||||||
unsigned char *to= *row;
|
unsigned char *to= *row;
|
||||||
@@ -701,6 +809,8 @@ static void convert_to_datetime(MYSQL_TIME *t, unsigned char **row, uint len, en
|
|||||||
if (len > 4)
|
if (len > 4)
|
||||||
{
|
{
|
||||||
t->hour= (uint) to[4];
|
t->hour= (uint) to[4];
|
||||||
|
if (type == MYSQL_TYPE_TIME)
|
||||||
|
t->hour+= t->day * 24;
|
||||||
t->minute= (uint) to[5];
|
t->minute= (uint) to[5];
|
||||||
t->second= (uint) to[6];
|
t->second= (uint) to[6];
|
||||||
if (has_date)
|
if (has_date)
|
||||||
@@ -747,12 +857,13 @@ void ps_fetch_datetime(MYSQL_BIND *r_param, const MYSQL_FIELD * field,
|
|||||||
MYSQL_TIME tm;
|
MYSQL_TIME tm;
|
||||||
unsigned int length;
|
unsigned int length;
|
||||||
convert_to_datetime(&tm, row, len, field->type);
|
convert_to_datetime(&tm, row, len, field->type);
|
||||||
|
/*
|
||||||
if (tm.time_type== MYSQL_TIMESTAMP_TIME && tm.day)
|
if (tm.time_type== MYSQL_TIMESTAMP_TIME && tm.day)
|
||||||
{
|
{
|
||||||
tm.hour+= tm.day * 24;
|
tm.hour+= tm.day * 24;
|
||||||
tm.day=0;
|
tm.day=0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
switch(field->type) {
|
switch(field->type) {
|
||||||
case MYSQL_TYPE_DATE:
|
case MYSQL_TYPE_DATE:
|
||||||
length= sprintf(dtbuffer, "%04u-%02u-%02u", tm.year, tm.month, tm.day);
|
length= sprintf(dtbuffer, "%04u-%02u-%02u", tm.year, tm.month, tm.day);
|
||||||
@@ -810,12 +921,26 @@ static
|
|||||||
void ps_fetch_bin(MYSQL_BIND *r_param, const MYSQL_FIELD *field,
|
void ps_fetch_bin(MYSQL_BIND *r_param, const MYSQL_FIELD *field,
|
||||||
unsigned char **row)
|
unsigned char **row)
|
||||||
{
|
{
|
||||||
ulong field_length= net_field_length(row);
|
ulong field_length;
|
||||||
size_t copylen;
|
size_t copylen;
|
||||||
|
|
||||||
/* Bug conc-155: For text columns we need to store terminating zero character */
|
|
||||||
if (!(field->flags & BINARY_FLAG) && r_param->buffer_type == MYSQL_TYPE_STRING)
|
/* If r_praram->buffer_type is not a binary type or binary_flag isn't set,
|
||||||
field_length++;
|
we do conversion from string */
|
||||||
|
if (!(field->flags & BINARY_FLAG) ||
|
||||||
|
(r_param->buffer_type != MYSQL_TYPE_NEWDECIMAL &&
|
||||||
|
r_param->buffer_type != MYSQL_TYPE_DECIMAL &&
|
||||||
|
r_param->buffer_type != MYSQL_TYPE_GEOMETRY &&
|
||||||
|
r_param->buffer_type != MYSQL_TYPE_ENUM &&
|
||||||
|
r_param->buffer_type != MYSQL_TYPE_SET &&
|
||||||
|
r_param->buffer_type != MYSQL_TYPE_TINY_BLOB &&
|
||||||
|
r_param->buffer_type != MYSQL_TYPE_MEDIUM_BLOB &&
|
||||||
|
r_param->buffer_type != MYSQL_TYPE_LONG_BLOB &&
|
||||||
|
r_param->buffer_type != MYSQL_TYPE_BLOB))
|
||||||
|
{
|
||||||
|
return ps_fetch_string(r_param, field, row);
|
||||||
|
}
|
||||||
|
field_length= net_field_length(row);
|
||||||
|
|
||||||
copylen= MIN(field_length, r_param->buffer_length);
|
copylen= MIN(field_length, r_param->buffer_length);
|
||||||
memcpy(r_param->buffer, *row, copylen);
|
memcpy(r_param->buffer, *row, copylen);
|
||||||
|
@@ -1236,6 +1236,9 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user,
|
|||||||
if (ma_net_init(net, pvio))
|
if (ma_net_init(net, pvio))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if (mysql->options.max_allowed_packet)
|
||||||
|
net->max_packet_size= mysql->options.max_allowed_packet;
|
||||||
|
|
||||||
ma_pvio_keepalive(net->pvio);
|
ma_pvio_keepalive(net->pvio);
|
||||||
strcpy(mysql->net.sqlstate, "00000");
|
strcpy(mysql->net.sqlstate, "00000");
|
||||||
|
|
||||||
|
@@ -359,7 +359,7 @@ MYSQL_RES *_mysql_stmt_use_result(MYSQL_STMT *stmt)
|
|||||||
MYSQL *mysql= stmt->mysql;
|
MYSQL *mysql= stmt->mysql;
|
||||||
|
|
||||||
if (!stmt->field_count ||
|
if (!stmt->field_count ||
|
||||||
(!stmt->cursor_exists && mysql->status != MYSQL_STATUS_GET_RESULT) ||
|
(!stmt->cursor_exists && mysql->status != MYSQL_STATUS_STMT_RESULT) ||
|
||||||
(stmt->cursor_exists && mysql->status != MYSQL_STATUS_READY) ||
|
(stmt->cursor_exists && mysql->status != MYSQL_STATUS_READY) ||
|
||||||
(stmt->state != MYSQL_STMT_WAITING_USE_OR_STORE))
|
(stmt->state != MYSQL_STMT_WAITING_USE_OR_STORE))
|
||||||
{
|
{
|
||||||
@@ -1220,6 +1220,7 @@ int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, size_t lengt
|
|||||||
int rc= 1;
|
int rc= 1;
|
||||||
enum mariadb_com_multi multi= MARIADB_COM_MULTI_END;
|
enum mariadb_com_multi multi= MARIADB_COM_MULTI_END;
|
||||||
|
|
||||||
|
|
||||||
if (!stmt->mysql)
|
if (!stmt->mysql)
|
||||||
{
|
{
|
||||||
SET_CLIENT_STMT_ERROR(stmt, CR_SERVER_LOST, SQLSTATE_UNKNOWN, 0);
|
SET_CLIENT_STMT_ERROR(stmt, CR_SERVER_LOST, SQLSTATE_UNKNOWN, 0);
|
||||||
@@ -1349,7 +1350,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
|
|||||||
return(1);
|
return(1);
|
||||||
/* todo: cursor */
|
/* todo: cursor */
|
||||||
}
|
}
|
||||||
else if (stmt->mysql->status != MYSQL_STATUS_GET_RESULT)
|
else if (stmt->mysql->status != MYSQL_STATUS_STMT_RESULT)
|
||||||
{
|
{
|
||||||
SET_CLIENT_ERROR(stmt->mysql, CR_COMMANDS_OUT_OF_SYNC, SQLSTATE_UNKNOWN, 0);
|
SET_CLIENT_ERROR(stmt->mysql, CR_COMMANDS_OUT_OF_SYNC, SQLSTATE_UNKNOWN, 0);
|
||||||
SET_CLIENT_STMT_ERROR(stmt, CR_COMMANDS_OUT_OF_SYNC, SQLSTATE_UNKNOWN, 0);
|
SET_CLIENT_STMT_ERROR(stmt, CR_COMMANDS_OUT_OF_SYNC, SQLSTATE_UNKNOWN, 0);
|
||||||
@@ -1534,10 +1535,12 @@ int stmt_read_execute_response(MYSQL_STMT *stmt)
|
|||||||
|
|
||||||
/* preferred is buffered read */
|
/* preferred is buffered read */
|
||||||
mysql_stmt_store_result(stmt);
|
mysql_stmt_store_result(stmt);
|
||||||
|
stmt->mysql->status= MYSQL_STATUS_STMT_RESULT;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
/* preferred is unbuffered read */
|
/* preferred is unbuffered read */
|
||||||
stmt->default_rset_handler = _mysql_stmt_use_result;
|
stmt->default_rset_handler = _mysql_stmt_use_result;
|
||||||
|
stmt->mysql->status= MYSQL_STATUS_STMT_RESULT;
|
||||||
}
|
}
|
||||||
stmt->state= MYSQL_STMT_WAITING_USE_OR_STORE;
|
stmt->state= MYSQL_STMT_WAITING_USE_OR_STORE;
|
||||||
/* in certain cases parameter types can change: For example see bug
|
/* in certain cases parameter types can change: For example see bug
|
||||||
@@ -1919,6 +1922,9 @@ int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt)
|
|||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stmt->mysql->status == MYSQL_STATUS_GET_RESULT)
|
||||||
|
stmt->mysql->status= MYSQL_STATUS_STMT_RESULT;
|
||||||
|
|
||||||
if (stmt->mysql->field_count)
|
if (stmt->mysql->field_count)
|
||||||
rc= madb_alloc_stmt_fields(stmt);
|
rc= madb_alloc_stmt_fields(stmt);
|
||||||
else
|
else
|
||||||
|
@@ -30,20 +30,20 @@ ENDIF()
|
|||||||
IF(AUTH_OLDPASSWORD_PLUGIN_TYPE MATCHES "DYNAMIC")
|
IF(AUTH_OLDPASSWORD_PLUGIN_TYPE MATCHES "DYNAMIC")
|
||||||
ADD_DEFINITIONS(-DHAVE_OLDPASSWORD_DYNAMIC=1)
|
ADD_DEFINITIONS(-DHAVE_OLDPASSWORD_DYNAMIC=1)
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
SET_VERSION_INFO("TARGET:old_password"
|
SET_VERSION_INFO("TARGET:mysql_old_password"
|
||||||
"FILE_TYPE:VFT_DLL"
|
"FILE_TYPE:VFT_DLL"
|
||||||
"SOURCE_FILE:plugins/auth/old_password.c"
|
"SOURCE_FILE:plugins/auth/old_password.c"
|
||||||
"ORIGINAL_FILE_NAME:old_password.dll"
|
"ORIGINAL_FILE_NAME:mysql_old_password.dll"
|
||||||
"FILE_DESCRIPTION:Authentication plugin")
|
"FILE_DESCRIPTION:Authentication plugin")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
SET(OLDPASSWORD_SOURCES ${old_password_RC} old_password.c)
|
SET(OLDPASSWORD_SOURCES ${old_password_RC} old_password.c)
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
SET(OLDPASSWORD_SOURCES ${DIALOG_SOURCES} ${CMAKE_SOURCE_DIR}/plugins/plugin.def)
|
SET(OLDPASSWORD_SOURCES ${DIALOG_SOURCES} ${CMAKE_SOURCE_DIR}/plugins/plugin.def)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ADD_LIBRARY(old_password SHARED ${OLDPASSWORD_SOURCES})
|
ADD_LIBRARY(mysql_old_password SHARED ${OLDPASSWORD_SOURCES})
|
||||||
SET_TARGET_PROPERTIES(old_password PROPERTIES PREFIX "")
|
SET_TARGET_PROPERTIES(mysql_old_password PROPERTIES PREFIX "")
|
||||||
INSTALL_PLUGIN(old_password ${CMAKE_BINARY_DIR}/plugins/auth)
|
INSTALL_PLUGIN(mysql_old_password ${CMAKE_BINARY_DIR}/plugins/auth)
|
||||||
SIGN_TARGET(old_password)
|
SIGN_TARGET(mysql_old_password)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# Cleartext
|
# Cleartext
|
||||||
|
@@ -80,7 +80,7 @@ static int native_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql)
|
|||||||
if (mysql && mysql->passwd[0])
|
if (mysql && mysql->passwd[0])
|
||||||
{
|
{
|
||||||
char scrambled[SCRAMBLE_LENGTH + 1];
|
char scrambled[SCRAMBLE_LENGTH + 1];
|
||||||
my_scramble_41((uchar *)scrambled, (char*)pkt, mysql->passwd);
|
ma_scramble_41((uchar *)scrambled, (char*)pkt, mysql->passwd);
|
||||||
if (vio->write_packet(vio, (uchar*)scrambled, SCRAMBLE_LENGTH))
|
if (vio->write_packet(vio, (uchar*)scrambled, SCRAMBLE_LENGTH))
|
||||||
return CR_ERROR;
|
return CR_ERROR;
|
||||||
}
|
}
|
||||||
|
@@ -101,7 +101,7 @@ static int auth_old_password(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql)
|
|||||||
if (mysql->passwd[0])
|
if (mysql->passwd[0])
|
||||||
{
|
{
|
||||||
char scrambled[SCRAMBLE_LENGTH_323 + 1];
|
char scrambled[SCRAMBLE_LENGTH_323 + 1];
|
||||||
scramble_323(scrambled, (char*)pkt, mysql->passwd);
|
ma_scramble_323(scrambled, (char*)pkt, mysql->passwd);
|
||||||
if (vio->write_packet(vio, (uchar*)scrambled, SCRAMBLE_LENGTH_323 + 1))
|
if (vio->write_packet(vio, (uchar*)scrambled, SCRAMBLE_LENGTH_323 + 1))
|
||||||
return CR_ERROR;
|
return CR_ERROR;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user