1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

BUG#30790 : Suspicious code in rpl_utility.cc

This patch clarifies some of the coding choices with documentationa and
removes a limitation in the code for future expansion of the CHAR and
BINARY fields to length > 255.


sql/field.cc:
  BUG#30790 : Suspicious code in rpl_utility.cc
  
  This patch adds an assertion to ensure we are not attempting to encode
  negative values.
sql/log_event.cc:
  BUG#30790 : Suspicious code in rpl_utility.cc
  
  This patch adds comments to help explain the choice of variable types.
sql/rpl_utility.cc:
  BUG#30790 : Suspicious code in rpl_utility.cc
  
  This patch removes code from the calc_field_size that is not needed and
  was ambiguous. Originally intended to future expansion, the code was
  not needed.
  
  Also added are comments to help explain some portions of the code.
  
  A change was made to the korr method to use the unsigned version to 
  avoid extended sign problems.
sql/rpl_utility.h:
  BUG#30790 : Suspicious code in rpl_utility.cc
  
  This patch corrects some type discrepencies and removes an extra cast.
This commit is contained in:
unknown
2007-09-14 11:22:41 -04:00
parent 0e466b540c
commit 431fd2c1aa
4 changed files with 41 additions and 20 deletions

View File

@ -99,7 +99,7 @@ public:
/*
These types store a single byte.
*/
m_field_metadata[i]= (uchar)field_metadata[index];
m_field_metadata[i]= field_metadata[index];
index++;
break;
}
@ -107,14 +107,14 @@ public:
case MYSQL_TYPE_ENUM:
case MYSQL_TYPE_STRING:
{
short int x= field_metadata[index++] << 8U; // real_type
x = x + field_metadata[index++]; // pack or field length
uint16 x= field_metadata[index++] << 8U; // real_type
x+= field_metadata[index++]; // pack or field length
m_field_metadata[i]= x;
break;
}
case MYSQL_TYPE_BIT:
{
short int x= field_metadata[index++];
uint16 x= field_metadata[index++];
x = x + (field_metadata[index++] << 8U);
m_field_metadata[i]= x;
break;
@ -125,14 +125,14 @@ public:
These types store two bytes.
*/
char *ptr= (char *)&field_metadata[index];
m_field_metadata[i]= sint2korr(ptr);
m_field_metadata[i]= uint2korr(ptr);
index= index + 2;
break;
}
case MYSQL_TYPE_NEWDECIMAL:
{
short int x= field_metadata[index++] << 8U; // precision
x = x + field_metadata[index++]; // decimals
uint16 x= field_metadata[index++] << 8U; // precision
x+= field_metadata[index++]; // decimals
m_field_metadata[i]= x;
break;
}