Skip to content

Commit 1a4234c

Browse files
author
Shishir Jaiswal
committed
Merge branch 'mysql-5.6' into mysql-5.7
2 parents e13cb39 + ab3d743 commit 1a4234c

File tree

14 files changed

+73
-49
lines changed

14 files changed

+73
-49
lines changed

client/base/mysql_query_runner.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ void Mysql_query_runner::append_escape_string(
303303

304304
int length = mysql_real_escape_string_quote(
305305
m_connection, &((*destination_string)[0]) + start_lenght, original,
306-
original_length, '"');
306+
(ulong)original_length, '"');
307307
destination_string->resize(start_lenght + length);
308308
}
309309

client/check/mysqlcheck_core.cc

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -228,7 +228,7 @@ static int rebuild_table(string name)
228228
{
229229
int rc= 0;
230230
string query= "ALTER TABLE " + name + " FORCE";
231-
if (mysql_real_query(sock, query.c_str(), (uint)query.length()))
231+
if (mysql_real_query(sock, query.c_str(), (ulong)query.length()))
232232
{
233233
fprintf(stderr, "Failed to %s\n", query.c_str());
234234
fprintf(stderr, "Error: %s\n", mysql_error(sock));
@@ -315,7 +315,7 @@ static int handle_request_for_tables(string tables)
315315

316316
string query= operation + " TABLE " + tables + " " + options;
317317

318-
if (mysql_real_query(sock, query.c_str(), query.length()))
318+
if (mysql_real_query(sock, query.c_str(), (ulong)query.length()))
319319
{
320320
DBError(sock,
321321
"when executing '" + operation + " TABLE ... " + options + "'");
@@ -394,7 +394,8 @@ static void print_result()
394394
if (strstr(alter_txt, "PARTITION BY") &&
395395
strlen(alter_txt) < MAX_ALTER_STR_SIZE)
396396
{
397-
strcpy(prev_alter, alter_txt);
397+
strncpy(prev_alter, alter_txt, MAX_ALTER_STR_SIZE-1);
398+
prev_alter[MAX_ALTER_STR_SIZE-1]= 0;
398399
}
399400
else
400401
{

client/dump/abstract_mysql_chain_element_extension.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ std::string Abstract_mysql_chain_element_extension::quote_name(
135135
Mysql::Tools::Base::Mysql_query_runner* runner= this->get_runner();
136136
buff[0]= '`';
137137
int len= mysql_real_escape_string_quote(runner->get_low_level_connection(),
138-
buff+1, name_str, name.size(), '`');
138+
buff+1, name_str, (ulong)name.size(), '`');
139139
buff[len+1]= '`';
140140
delete runner;
141141
return std::string(buff);

client/mysql.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3346,7 +3346,7 @@ int mysql_real_query_for_lazy(const char *buf, size_t length)
33463346
for (uint retry=0;; retry++)
33473347
{
33483348
int error;
3349-
if (!mysql_real_query(&mysql,buf,length))
3349+
if (!mysql_real_query(&mysql,buf,(ulong)length))
33503350
return 0;
33513351
error= put_error(&mysql);
33523352
if (mysql_errno(&mysql) != CR_SERVER_GONE_ERROR || retry > 1 ||

client/mysql_secure_installation.cc

+15-9
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ void execute_query_with_message(const char *query, const char *opt_message)
261261
*/
262262
bool execute_query(const char **query, size_t length)
263263
{
264-
if (!mysql_real_query(&mysql, (const char *) *query, length))
264+
if (!mysql_real_query(&mysql, (const char *) *query, (ulong)length))
265265
return FALSE;
266266
else if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR)
267267
{
@@ -374,7 +374,8 @@ int install_password_validation_plugin()
374374
MYF(MY_WME));
375375
end= my_stpcpy(query, "SET GLOBAL validate_password_policy = ");
376376
*end++ = '\'';
377-
end+= mysql_real_escape_string_quote(&mysql, end, strength, strength_length, '\'');
377+
end+= mysql_real_escape_string_quote(&mysql, end, strength,
378+
(ulong)strength_length, '\'');
378379
*end++ = '\'';
379380
if (!execute_query((const char **) &query,(unsigned int) (end-query)))
380381
DBUG_PRINT("info", ("query success!"));
@@ -407,7 +408,8 @@ void estimate_password_strength(char *password_string)
407408
MYF(MY_WME));
408409
end= my_stpcpy(query, "SELECT validate_password_strength(");
409410
*end++ = '\'';
410-
end+= mysql_real_escape_string_quote(&mysql, end, password_string, password_length, '\'');
411+
end+= mysql_real_escape_string_quote(&mysql, end, password_string,
412+
(ulong)password_length, '\'');
411413
*end++ = '\'';
412414
*end++ = ')';
413415
if (!execute_query((const char **) &query,(unsigned int) (end-query)))
@@ -444,9 +446,10 @@ my_bool mysql_set_password(MYSQL *mysql, char *password)
444446
query= (char *)my_malloc(PSI_NOT_INSTRUMENTED, password_len+50, MYF(MY_WME));
445447
end= my_stpmov(query, "SET PASSWORD=");
446448
*end++ = '\'';
447-
end+= mysql_real_escape_string_quote(mysql, end, password, password_len, '\'');
449+
end+= mysql_real_escape_string_quote(mysql, end, password,
450+
(ulong)password_len, '\'');
448451
*end++ = '\'';
449-
if (mysql_real_query(mysql, query, (unsigned int) (end - query)))
452+
if (mysql_real_query(mysql, query, (ulong) (end - query)))
450453
{
451454
my_free(query);
452455
return FALSE;
@@ -478,7 +481,7 @@ my_bool mysql_expire_password(MYSQL *mysql)
478481
{
479482
char sql[]= "UPDATE mysql.user SET password_expired= 'Y'";
480483
size_t sql_len= strlen(sql);
481-
if (mysql_real_query(mysql, sql, sql_len))
484+
if (mysql_real_query(mysql, sql, (ulong)sql_len))
482485
return FALSE;
483486

484487
return TRUE;
@@ -552,7 +555,8 @@ static void set_opt_user_password(int plugin_set)
552555
(pass_length*2 + tmp)*sizeof(char), MYF(MY_WME));
553556
end= my_stpcpy(query, "SET PASSWORD=");
554557
*end++ = '\'';
555-
end+= mysql_real_escape_string_quote(&mysql, end, password1, pass_length, '\'');
558+
end+= mysql_real_escape_string_quote(&mysql, end, password1,
559+
(ulong)pass_length, '\'');
556560
*end++ = '\'';
557561
my_free(password1);
558562
my_free(password2);
@@ -709,11 +713,13 @@ void drop_users(MYSQL_RES *result)
709713
sizeof(char), MYF(MY_WME));
710714
end= my_stpcpy(query, "DROP USER ");
711715
*end++ = '\'';
712-
end+= mysql_real_escape_string_quote(&mysql, end, user_tmp, user_length, '\'');
716+
end+= mysql_real_escape_string_quote(&mysql, end, user_tmp,
717+
(ulong)user_length, '\'');
713718
*end++ = '\'';
714719
*end++ = '@';
715720
*end++ = '\'';
716-
end+= mysql_real_escape_string_quote(&mysql, end, host_tmp, host_length, '\'');
721+
end+= mysql_real_escape_string_quote(&mysql, end, host_tmp,
722+
(ulong)host_length, '\'');
717723
*end++ = '\'';
718724
if (!execute_query((const char **) &query, (unsigned int) (end-query)))
719725
DBUG_PRINT("info", ("query success!"));

client/mysqladmin.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
10541054
/* escape quotes if password has any special characters */
10551055
password_len= strlen(typed_password);
10561056
tmp= (char*) my_malloc(PSI_NOT_INSTRUMENTED, password_len*2+1, MYF(MY_WME));
1057-
mysql_real_escape_string(mysql, tmp, typed_password, password_len);
1057+
mysql_real_escape_string(mysql, tmp, typed_password, (ulong)password_len);
10581058
typed_password= tmp;
10591059
}
10601060
else

client/mysqldump.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989

9090
static void add_load_option(DYNAMIC_STRING *str, const char *option,
9191
const char *option_value);
92-
static ulong find_set(TYPELIB *lib, const char *x, uint length,
92+
static ulong find_set(TYPELIB *lib, const char *x, size_t length,
9393
char **err_pos, uint *err_len);
9494
static char *alloc_query_str(size_t size);
9595

@@ -910,7 +910,7 @@ get_one_option(int optid, const struct my_option *opt MY_ATTRIBUTE((unused)),
910910
opt_set_charset= 0;
911911
opt_compatible_mode_str= argument;
912912
opt_compatible_mode= find_set(&compatible_mode_typelib,
913-
argument, (uint) strlen(argument),
913+
argument, strlen(argument),
914914
&err_ptr, &err_len);
915915
if (err_len)
916916
{
@@ -1236,8 +1236,8 @@ static int fetch_db_collation(const char *db_name,
12361236
break;
12371237
}
12381238

1239-
strncpy(db_cl_name, db_cl_row[0], db_cl_size);
1240-
db_cl_name[db_cl_size - 1]= 0; /* just in case. */
1239+
strncpy(db_cl_name, db_cl_row[0], db_cl_size-1);
1240+
db_cl_name[db_cl_size - 1]= 0;
12411241

12421242
} while (FALSE);
12431243

@@ -1721,15 +1721,15 @@ static void dbDisconnect(char *host)
17211721
} /* dbDisconnect */
17221722

17231723

1724-
static void unescape(FILE *file,char *pos,uint length)
1724+
static void unescape(FILE *file,char *pos, size_t length)
17251725
{
17261726
char *tmp;
17271727
DBUG_ENTER("unescape");
17281728
if (!(tmp=(char*) my_malloc(PSI_NOT_INSTRUMENTED,
17291729
length*2+1, MYF(MY_WME))))
17301730
die(EX_MYSQLERR, "Couldn't allocate memory");
17311731

1732-
mysql_real_escape_string_quote(&mysql_connection, tmp, pos, length, '\'');
1732+
mysql_real_escape_string_quote(&mysql_connection, tmp, pos, (ulong)length, '\'');
17331733
fputc('\'', file);
17341734
fputs(tmp, file);
17351735
fputc('\'', file);
@@ -2481,9 +2481,9 @@ static uint dump_routines_for_db(char *db)
24812481
if the user has EXECUTE privilege he see routine names, but NOT the
24822482
routine body of other routines that are not the creator of!
24832483
*/
2484-
DBUG_PRINT("info",("length of body for %s row[2] '%s' is %d",
2484+
DBUG_PRINT("info",("length of body for %s row[2] '%s' is %zu",
24852485
routine_name, row[2] ? row[2] : "(null)",
2486-
row[2] ? (int) strlen(row[2]) : 0));
2486+
row[2] ? strlen(row[2]) : 0));
24872487
if (row[2] == NULL)
24882488
{
24892489
print_comment(sql_file, 1, "\n-- insufficient privileges to %s\n",
@@ -5312,7 +5312,7 @@ static int start_transaction(MYSQL *mysql_con)
53125312
}
53135313

53145314

5315-
static ulong find_set(TYPELIB *lib, const char *x, uint length,
5315+
static ulong find_set(TYPELIB *lib, const char *x, size_t length,
53165316
char **err_pos, uint *err_len)
53175317
{
53185318
const char *end= x + length;
@@ -5370,7 +5370,7 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
53705370
fputc(' ',file);
53715371
fputs(prefix, file);
53725372
if (string_value)
5373-
unescape(file,row[0],(uint) strlen(row[0]));
5373+
unescape(file,row[0], strlen(row[0]));
53745374
else
53755375
fputs(row[0], file);
53765376
check_io(file);

client/mysqlshow.c

+19-17
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ static int list_tables(MYSQL *mysql,const char *db,const char *table);
5555
static int list_table_status(MYSQL *mysql,const char *db,const char *table);
5656
static int list_fields(MYSQL *mysql,const char *db,const char *table,
5757
const char *field);
58-
static void print_header(const char *header,uint head_length,...);
59-
static void print_row(const char *header,uint head_length,...);
60-
static void print_trailer(uint length,...);
58+
static void print_header(const char *header,size_t head_length,...);
59+
static void print_row(const char *header,size_t head_length,...);
60+
static void print_trailer(size_t length,...);
6161
static void print_res_header(MYSQL_RES *result);
6262
static void print_res_top(MYSQL_RES *result);
6363
static void print_res_row(MYSQL_RES *result,MYSQL_ROW cur);
@@ -411,7 +411,8 @@ static int
411411
list_dbs(MYSQL *mysql,const char *wild)
412412
{
413413
const char *header;
414-
uint length, counter = 0;
414+
size_t length = 0;
415+
uint counter = 0;
415416
ulong rowcount = 0L;
416417
char tables[NAME_LEN+1], rows[NAME_LEN+1];
417418
char query[NAME_LEN + 100];
@@ -449,7 +450,7 @@ list_dbs(MYSQL *mysql,const char *wild)
449450
printf("Wildcard: %s\n",wild);
450451

451452
header="Databases";
452-
length=(uint) strlen(header);
453+
length= strlen(header);
453454
field=mysql_fetch_field(result);
454455
if (length < field->max_length)
455456
length=field->max_length;
@@ -537,7 +538,8 @@ static int
537538
list_tables(MYSQL *mysql,const char *db,const char *table)
538539
{
539540
const char *header;
540-
uint head_length, counter = 0;
541+
size_t head_length;
542+
uint counter = 0;
541543
char query[NAME_LEN + 100], rows[NAME_LEN], fields[16];
542544
MYSQL_FIELD *field;
543545
MYSQL_RES *result;
@@ -575,7 +577,7 @@ list_tables(MYSQL *mysql,const char *db,const char *table)
575577
putchar('\n');
576578

577579
header="Tables";
578-
head_length=(uint) strlen(header);
580+
head_length= strlen(header);
579581
field=mysql_fetch_field(result);
580582
if (head_length < field->max_length)
581583
head_length=field->max_length;
@@ -805,10 +807,10 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
805807
*****************************************************************************/
806808

807809
static void
808-
print_header(const char *header,uint head_length,...)
810+
print_header(const char *header,size_t head_length,...)
809811
{
810812
va_list args;
811-
uint length,i,str_length,pre_space;
813+
size_t length,i,str_length,pre_space;
812814
const char *field;
813815

814816
va_start(args,head_length);
@@ -831,10 +833,10 @@ print_header(const char *header,uint head_length,...)
831833
putchar('|');
832834
for (;;)
833835
{
834-
str_length=(uint) strlen(field);
836+
str_length= strlen(field);
835837
if (str_length > length)
836838
str_length=length+1;
837-
pre_space=(uint) (((int) length-(int) str_length)/2)+1;
839+
pre_space= ((length- str_length)/2)+1;
838840
for (i=0 ; i < pre_space ; i++)
839841
putchar(' ');
840842
for (i = 0 ; i < str_length ; i++)
@@ -868,11 +870,11 @@ print_header(const char *header,uint head_length,...)
868870

869871

870872
static void
871-
print_row(const char *header,uint head_length,...)
873+
print_row(const char *header,size_t head_length,...)
872874
{
873875
va_list args;
874876
const char *field;
875-
uint i,length,field_length;
877+
size_t i,length,field_length;
876878

877879
va_start(args,head_length);
878880
field=header; length=head_length;
@@ -881,7 +883,7 @@ print_row(const char *header,uint head_length,...)
881883
putchar('|');
882884
putchar(' ');
883885
fputs(field,stdout);
884-
field_length=(uint) strlen(field);
886+
field_length= strlen(field);
885887
for (i=field_length ; i <= length ; i++)
886888
putchar(' ');
887889
if (!(field=va_arg(args,char *)))
@@ -895,10 +897,10 @@ print_row(const char *header,uint head_length,...)
895897

896898

897899
static void
898-
print_trailer(uint head_length,...)
900+
print_trailer(size_t head_length,...)
899901
{
900902
va_list args;
901-
uint length,i;
903+
size_t length,i;
902904

903905
va_start(args,head_length);
904906
length=head_length;
@@ -941,7 +943,7 @@ static void print_res_top(MYSQL_RES *result)
941943
mysql_field_seek(result,0);
942944
while((field = mysql_fetch_field(result)))
943945
{
944-
if ((length=(uint) strlen(field->name)) > field->max_length)
946+
if ((length= strlen(field->name)) > field->max_length)
945947
field->max_length=length;
946948
else
947949
length=field->max_length;

extra/yassl/src/log.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -60,6 +60,7 @@ namespace yaSSL {
6060
time_t clicks = time(0);
6161
char timeStr[32];
6262

63+
memset(timeStr, 0, sizeof(timeStr));
6364
// get rid of newline
6465
strncpy(timeStr, ctime(&clicks), sizeof(timeStr));
6566
unsigned int len = strlen(timeStr);

plugin/innodb_memcached/daemon_memcached/utilities/engine_loader.c

+7
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ void log_engine_details(ENGINE_HANDLE * engine,
137137
offset += nw;
138138
for (int ii = 0; ii < info->num_features; ++ii) {
139139
if (info->features[ii].description != NULL) {
140+
// We don't want to write partially from source
141+
if (sizeof(message)-offset <=
142+
2+strlen(info->features[ii].description))
143+
{
144+
return;
145+
}
146+
140147
nw = snprintf(message + offset, sizeof(message) - offset,
141148
"%s%s", comma ? ", " : "",
142149
info->features[ii].description);

plugin/innodb_memcached/innodb_memcache/src/innodb_engine.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/***********************************************************************
22
3-
Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
3+
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
44
55
This program is free software; you can redistribute it and/or modify it
66
under the terms of the GNU General Public License as published by the
@@ -1929,6 +1929,9 @@ innodb_get(
19291929
&col_value->value_int,
19301930
col_value->value_len,
19311931
col_value->is_unsigned);
1932+
1933+
assert(int_len <= conn_data->mul_col_buf_len);
1934+
19321935
memcpy(c_value, int_buf, int_len);
19331936
c_value += int_len;
19341937
} else {

0 commit comments

Comments
 (0)