Skip to content

Commit c44b180

Browse files
author
Tor Didriksen
committed
Bug #30150719 INCORRECT LENGTH IN READ_OK_EX()
Fix warnings from clang 8 and gcc 8. Change-Id: I7a44c6758764621033bb41badb6f58927993f362
1 parent 19a667b commit c44b180

File tree

7 files changed

+31
-31
lines changed

7 files changed

+31
-31
lines changed

rapid/plugin/group_replication/src/sql_service/sql_service_interface.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2015, 2019, 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,
@@ -25,7 +25,7 @@
2525
#include <mysqld_error.h>
2626

2727
/* keep it in sync with enum_server_command in my_command.h */
28-
const LEX_STRING command_name[]={
28+
const LEX_STRING command_name[] MY_ATTRIBUTE((unused)) = {
2929
{ C_STRING_WITH_LEN("Sleep") },
3030
{ C_STRING_WITH_LEN("Quit") },
3131
{ C_STRING_WITH_LEN("Init DB") },

sql-common/client.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -813,9 +813,7 @@ void read_ok_ex(MYSQL *mysql, ulong length) {
813813

814814
if (is_charset == 1) {
815815
char charset_name[MY_CS_NAME_SIZE * 8]; // MY_CS_BUFFER_SIZE
816-
size_t length = data->length > (sizeof(charset_name) - 1)
817-
? sizeof(charset_name - 1)
818-
: data->length;
816+
size_t length = MY_MIN(data->length, (sizeof(charset_name) - 1));
819817
saved_cs = mysql->charset;
820818

821819
memcpy(charset_name, data->str, length);

sql/log_event.cc

+15-15
Original file line numberDiff line numberDiff line change
@@ -7583,7 +7583,7 @@ int User_var_log_event::pack_info(Protocol* protocol)
75837583
else
75847584
{
75857585
switch (type) {
7586-
case REAL_RESULT:
7586+
case REAL_TYPE:
75877587
double real_val;
75887588
float8get(&real_val, val);
75897589
if (!(buf= (char*) my_malloc(key_memory_log_event,
@@ -7593,15 +7593,15 @@ int User_var_log_event::pack_info(Protocol* protocol)
75937593
event_len+= my_gcvt(real_val, MY_GCVT_ARG_DOUBLE, MY_GCVT_MAX_FIELD_WIDTH,
75947594
buf + val_offset, NULL);
75957595
break;
7596-
case INT_RESULT:
7596+
case INT_TYPE:
75977597
if (!(buf= (char*) my_malloc(key_memory_log_event,
75987598
val_offset + 22, MYF(MY_WME))))
75997599
return 1;
76007600
event_len= longlong10_to_str(uint8korr(val), buf + val_offset,
76017601
((flags & User_var_log_event::UNSIGNED_F) ?
76027602
10 : -10))-buf;
76037603
break;
7604-
case DECIMAL_RESULT:
7604+
case DECIMAL_TYPE:
76057605
{
76067606
if (!(buf= (char*) my_malloc(key_memory_log_event,
76077607
val_offset + DECIMAL_MAX_STR_LENGTH + 1,
@@ -7615,7 +7615,7 @@ int User_var_log_event::pack_info(Protocol* protocol)
76157615
event_len= str.length() + val_offset;
76167616
break;
76177617
}
7618-
case STRING_RESULT:
7618+
case STRING_TYPE:
76197619
/* 15 is for 'COLLATE' and other chars */
76207620
buf= (char*) my_malloc(key_memory_log_event,
76217621
event_len+val_len*2+1+2*MY_CS_NAME_SIZE+15,
@@ -7636,7 +7636,7 @@ int User_var_log_event::pack_info(Protocol* protocol)
76367636
event_len= p-buf;
76377637
}
76387638
break;
7639-
case ROW_RESULT:
7639+
case ROW_TYPE:
76407640
default:
76417641
DBUG_ASSERT(1);
76427642
return 1;
@@ -7690,14 +7690,14 @@ bool User_var_log_event::write(IO_CACHE* file)
76907690
int4store(buf1 + 2, charset_number);
76917691

76927692
switch (type) {
7693-
case REAL_RESULT:
7693+
case REAL_TYPE:
76947694
float8store(buf2, *(double*) val);
76957695
break;
7696-
case INT_RESULT:
7696+
case INT_TYPE:
76977697
int8store(buf2, *(longlong*) val);
76987698
unsigned_len= 1;
76997699
break;
7700-
case DECIMAL_RESULT:
7700+
case DECIMAL_TYPE:
77017701
{
77027702
my_decimal *dec= (my_decimal *)val;
77037703
dec->sanity_check();
@@ -7707,10 +7707,10 @@ bool User_var_log_event::write(IO_CACHE* file)
77077707
val_len= decimal_bin_size(buf2[0], buf2[1]) + 2;
77087708
break;
77097709
}
7710-
case STRING_RESULT:
7710+
case STRING_TYPE:
77117711
pos= (uchar*) val;
77127712
break;
7713-
case ROW_RESULT:
7713+
case ROW_TYPE:
77147714
default:
77157715
DBUG_ASSERT(1);
77167716
return 0;
@@ -7895,7 +7895,7 @@ int User_var_log_event::do_apply_event(Relay_log_info const *rli)
78957895
else
78967896
{
78977897
switch (type) {
7898-
case REAL_RESULT:
7898+
case REAL_TYPE:
78997899
if (val_len != 8)
79007900
{
79017901
rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,
@@ -7908,7 +7908,7 @@ int User_var_log_event::do_apply_event(Relay_log_info const *rli)
79087908
val= (char*) &real_val; // Pointer to value in native format
79097909
val_len= 8;
79107910
break;
7911-
case INT_RESULT:
7911+
case INT_TYPE:
79127912
if (val_len != 8)
79137913
{
79147914
rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,
@@ -7921,7 +7921,7 @@ int User_var_log_event::do_apply_event(Relay_log_info const *rli)
79217921
val= (char*) &int_val; // Pointer to value in native format
79227922
val_len= 8;
79237923
break;
7924-
case DECIMAL_RESULT:
7924+
case DECIMAL_TYPE:
79257925
{
79267926
if (val_len < 3)
79277927
{
@@ -7936,10 +7936,10 @@ int User_var_log_event::do_apply_event(Relay_log_info const *rli)
79367936
val_len= sizeof(my_decimal);
79377937
break;
79387938
}
7939-
case STRING_RESULT:
7939+
case STRING_TYPE:
79407940
it= new Item_string(val, val_len, charset);
79417941
break;
7942-
case ROW_RESULT:
7942+
case ROW_TYPE:
79437943
default:
79447944
DBUG_ASSERT(1);
79457945
DBUG_RETURN(0);

sql/sql_join_buffer.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,9 @@ class JOIN_CACHE :public QEP_operation
359359
/* Shall calculate how much space is remaining in the join buffer */
360360
virtual ulong rem_space()
361361
{
362-
return std::max<ulong>(buff_size-(end_pos-buff)-aux_buff_size, 0UL);
362+
DBUG_ASSERT(end_pos >= buff);
363+
DBUG_ASSERT(buff_size >= ulong(end_pos - buff));
364+
return ulong(buff_size - (end_pos - buff) - aux_buff_size);
363365
}
364366

365367
/* Shall skip record from the join buffer if its match flag is on */
@@ -829,8 +831,10 @@ class JOIN_CACHE_BKA_UNIQUE :public JOIN_CACHE_BKA
829831
*/
830832
ulong rem_space()
831833
{
832-
return std::max(static_cast<ulong>(last_key_entry - end_pos-aux_buff_size),
833-
0UL);
834+
DBUG_ASSERT(last_key_entry >= end_pos);
835+
DBUG_ASSERT(buff_size >= aux_buff_size);
836+
DBUG_ASSERT(ulong(last_key_entry - end_pos) >= aux_buff_size);
837+
return ulong(last_key_entry - end_pos - aux_buff_size);
834838
}
835839

836840
/*

storage/innobase/fts/fts0opt.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ fts_fetch_index_words(
687687
fts_zip_t* zip = static_cast<fts_zip_t*>(user_arg);
688688
que_node_t* exp = sel_node->select_list;
689689
dfield_t* dfield = que_node_get_val(exp);
690-
short len = static_cast<short>(dfield_get_len(dfield));
690+
ushort len = static_cast<ushort>(dfield_get_len(dfield));
691691
void* data = dfield_get_data(dfield);
692692

693693
/* Skip the duplicate words. */

storage/perfschema/pfs_builtin_memory.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2014, 2019, 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,
@@ -21,6 +21,7 @@
2121
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
2222

2323
#include "my_global.h"
24+
#include "m_string.h"
2425
#include "pfs_global.h"
2526
#include "pfs_builtin_memory.h"
2627

@@ -115,7 +116,8 @@ static void init_builtin_memory_class(PFS_builtin_memory_class *klass, const cha
115116
klass->m_class.m_timed= false; /* Immutable */
116117
klass->m_class.m_flags= PSI_FLAG_GLOBAL;
117118
klass->m_class.m_event_name_index= 0;
118-
strncpy(klass->m_class.m_name, name, sizeof(klass->m_class.m_name));
119+
my_snprintf(klass->m_class.m_name, sizeof(klass->m_class.m_name), "%.*s",
120+
PFS_MAX_INFO_NAME_LENGTH - 1, name);
119121
klass->m_class.m_name_length= strlen(name);
120122
DBUG_ASSERT(klass->m_class.m_name_length < sizeof(klass->m_class.m_name));
121123
klass->m_class.m_timer= NULL;

unittest/gunit/gis_algos-t.cc

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2014, 2019, 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,
@@ -259,10 +259,6 @@ TEST_F(GeometryManipulationTest, PolygonManipulationTest)
259259
ls0->get_flags(), ls0->get_srid());
260260
Gis_line_string ls00(*ls0);
261261

262-
ls= ls;
263-
ls00= ls00;
264-
plgn= plgn;
265-
266262
Geometry_buffer buffer3;
267263
String wkt3, str3;
268264

0 commit comments

Comments
 (0)