MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Chad MILLER Date:January 17 2007 10:46pm
Subject:bk commit into 4.1 tree (cmiller:1.2598) BUG#12194
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of cmiller. When cmiller does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-01-17 17:46:26-05:00, cmiller@stripped +1 -0
  Bug#12194: Valgrind: Source and destination overlap in memcpy
  
  memcpy() must not be given two memory regions that overlap.  memmove()
  handles such memory properly and costs little extra.
  
  I found one instance in my valgrind run of 5.1, in test "sp":
  ==7769== Source and destination overlap in memcpy(0x76D76A1, 0x76D76A1, 1)
  ==7769==    at 0x4022C36: memcpy (mc_replace_strmem.c:116)
  ==7769==    by 0x836FF37: field_conv(Field*, Field*) (field_conv.cc:708)
  ==7769==    by 0x817E2A1: Item_field::save_in_field(Field*, bool) (item.cc:4318)
  ==7769==    by 0x83C89C6: sp_eval_expr(THD*, Field*, Item**) (sp_head.cc:361)
  ==7769==    by 0x83D1CF6: sp_rcontext::set_variable(THD*, Field*, Item**) (sp_rcontext.cc:355)
  ==7769==    by 0x83D1D2A: sp_rcontext::set_variable(THD*, unsigned, Item**) (sp_rcontext.cc:342)
  ==7769==    by 0x821559D: select_dumpvar::send_data(List<Item>&) (sql_class.cc:1958)

  sql/field_conv.cc@stripped, 2007-01-17 17:46:25-05:00, cmiller@stripped +8 -8
    Replace memcpy() with memmove().

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	cmiller
# Host:	zippy.cornsilk.net
# Root:	/home/cmiller/work/mysql/memcpy/my41-memcpy

--- 1.38/sql/field_conv.cc	2007-01-17 17:46:29 -05:00
+++ 1.39/sql/field_conv.cc	2007-01-17 17:46:29 -05:00
@@ -26,7 +26,7 @@
 
 static void do_field_eq(Copy_field *copy)
 {
-  memcpy(copy->to_ptr,copy->from_ptr,copy->from_length);
+  memmove(copy->to_ptr,copy->from_ptr,copy->from_length);
 }
 
 static void do_field_1(Copy_field *copy)
@@ -88,7 +88,7 @@ static void do_field_to_null_str(Copy_fi
   else
   {
     copy->to_null_ptr[0]=0;
-    memcpy(copy->to_ptr,copy->from_ptr,copy->from_length);
+    memmove(copy->to_ptr,copy->from_ptr,copy->from_length);
   }
 }
 
@@ -104,7 +104,7 @@ static void do_outer_field_to_null_str(C
   else
   {
     copy->to_null_ptr[0]=0;
-    memcpy(copy->to_ptr,copy->from_ptr,copy->from_length);
+    memmove(copy->to_ptr,copy->from_ptr,copy->from_length);
   }
 }
 
@@ -332,7 +332,7 @@ static void do_field_real(Copy_field *co
 static void do_cut_string(Copy_field *copy)
 {
   CHARSET_INFO *cs= copy->from_field->charset();
-  memcpy(copy->to_ptr,copy->from_ptr,copy->to_length);
+  memmove(copy->to_ptr,copy->from_ptr,copy->to_length);
 
   /* Check if we loosed any important characters */
   if (cs->cset->scan(cs,
@@ -361,7 +361,7 @@ static void do_cut_string_complex(Copy_f
                                               &well_formed_error);
   if (copy->to_length < copy_length)
     copy_length= copy->to_length;
-  memcpy(copy->to_ptr, copy->from_ptr, copy_length);
+  memmove(copy->to_ptr, copy->from_ptr, copy_length);
 
   /* Check if we lost any important characters */
   if (well_formed_error ||
@@ -383,7 +383,7 @@ static void do_cut_string_complex(Copy_f
 static void do_expand_string(Copy_field *copy)
 {
   CHARSET_INFO *cs= copy->from_field->charset();
-  memcpy(copy->to_ptr,copy->from_ptr,copy->from_length);
+  memmove(copy->to_ptr,copy->from_ptr,copy->from_length);
   cs->cset->fill(cs, copy->to_ptr+copy->from_length,
                      copy->to_length-copy->from_length, ' ');
 }
@@ -399,7 +399,7 @@ static void do_varstring(Copy_field *cop
                                   ER_WARN_DATA_TRUNCATED, 1);
   }
   int2store(copy->to_ptr,length);
-  memcpy(copy->to_ptr+2, copy->from_ptr,length);
+  memmove(copy->to_ptr+2, copy->from_ptr,length);
 }
 
 /***************************************************************************
@@ -605,7 +605,7 @@ void field_conv(Field *to,Field *from)
         from->charset() == to->charset() &&
 	to->table->db_low_byte_first == from->table->db_low_byte_first)
     {						// Identical fields
-      memcpy(to->ptr,from->ptr,to->pack_length());
+      memmove(to->ptr,from->ptr,to->pack_length());
       return;
     }
   }
Thread
bk commit into 4.1 tree (cmiller:1.2598) BUG#12194Chad MILLER17 Jan