~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/stored_key.h

  • Committer: Monty Taylor
  • Date: 2009-08-29 19:30:29 UTC
  • mto: (1126.5.1 captain-20090914-03)
  • mto: This revision was merged to the branch mainline in revision 1129.
  • Revision ID: mordred@inaugust.com-20090829193029-i12fw4pg91dm8nu9
Fixed a buffer overrun that was causing some translated message output to suck.

Honestly guys, declaring a char[80] and then doing an sprintf into it with
no length checking? sigh

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#ifndef DRIZZLED_STORED_KEY_H
21
21
#define DRIZZLED_STORED_KEY_H
22
22
 
23
 
namespace drizzled
24
 
{
25
 
 
26
23
/** class to store an field/item as a key struct */
27
 
class StoredKey :public memory::SqlAlloc
 
24
class StoredKey :public Sql_alloc
28
25
{
29
26
public:
30
27
  bool null_key; /**< If true, the value of the key has a null part */
56
53
        Key segments are always packed with a 2 byte length prefix.
57
54
        See mi_rkey for details.
58
55
      */
59
 
      to_field= new Field_varstring(ptr,
60
 
                                    length,
61
 
                                    2,
62
 
                                    null,
63
 
                                    1,
64
 
                                    field_arg->field_name,
65
 
                                    field_arg->charset());
66
 
      to_field->init(field_arg->getTable());
 
56
      to_field= new Field_varstring(ptr, length, 2, null, 1,
 
57
                                    Field::NONE, field_arg->field_name,
 
58
                                    field_arg->table->s, field_arg->charset());
 
59
      to_field->init(field_arg->table);
67
60
    }
68
61
    else
69
 
      to_field= field_arg->new_key_field(session->mem_root, field_arg->getTable(),
 
62
      to_field= field_arg->new_key_field(session->mem_root, field_arg->table,
70
63
                                        ptr, null, 1);
71
64
 
72
65
    to_field->setWriteSet();
83
76
  enum store_key_result copy()
84
77
  {
85
78
    enum store_key_result result;
86
 
    Session *session= to_field->getTable()->in_use;
 
79
    Session *session= to_field->table->in_use;
87
80
    enum_check_fields saved_count_cuted_fields= session->count_cuted_fields;
88
81
    session->count_cuted_fields= CHECK_FIELD_IGNORE;
89
82
    result= copy_inner();
175
168
  }
176
169
};
177
170
 
178
 
} /* namespace drizzled */
179
 
 
180
171
#endif /* DRIZZLED_STORED_KEY_H */