[Commits] 53363bd: MDEV-11645: archive.archive fails in buildbot with valgrind (Use of uninitialised value)

Varun varunraiko1803 at gmail.com
Wed Mar 15 11:20:21 EET 2017


revision-id: 53363bd5fb3e29e6d92a90cec3febdb3cadbc17f (mariadb-10.2.3-283-g53363bd)
parent(s): b13cee83f9cfcffa98d227c492411a9acec85f42
author: Varun Gupta
committer: Varun Gupta
timestamp: 2017-03-15 14:49:50 +0530
message:

MDEV-11645: archive.archive fails in buildbot with valgrind (Use of uninitialised value)

The fix is about filling the space beyond the end of VARCHAR values with zeroes.
VARCHAR NULLs already has its buffer filled with zeros. So when the VARCHAR fields
are not NULL, then we explicitly fill the buffer with zeros.

---
 storage/archive/ha_archive.cc | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index 9d6d100..fc1ec17 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -372,10 +372,30 @@ int Archive_share::write_v1_metafile()
 
 unsigned int ha_archive::pack_row_v1(uchar *record)
 {
+  uint offset;
   uint *blob, *end;
   uchar *pos;
   DBUG_ENTER("pack_row_v1");
   memcpy(record_buffer->buffer, record, table->s->reclength);
+
+  /* The end of VARCHAR fields are filled with garbage,so here
+     we explicitly set the end of the VARCHAR fields with zeroes */
+
+  for (Field** field= table->field; (*field) ; field++)
+  {
+    Field *fld= *field;
+    if (fld->type() == MYSQL_TYPE_VARCHAR)
+    {
+      if (!(fld->is_real_null(record - table->record[0])))
+      {
+        ptrdiff_t  start= (fld->ptr - table->record[0]);
+        Field_varstring *const field_var= (Field_varstring *)fld;
+        offset= field_var->data_length() + field_var->length_size();
+        memset(record_buffer->buffer + start + offset, 0,
+                        fld->field_length - offset + 1);
+      }
+    }
+  }
   pos= record_buffer->buffer + table->s->reclength;
   for (blob= table->s->blob_field, end= blob + table->s->blob_fields;
        blob != end; blob++)


More information about the commits mailing list