Bug #26969 Field_bit::pack() and Field_bit::unpack() does not work correctly
Submitted: 8 Mar 2007 20:17 Modified: 4 Apr 2007 3:26
Reporter: Mats Kindahl Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: Mats Kindahl CPU Architecture:Any

[8 Mar 2007 20:17] Mats Kindahl
Description:
Field_bit::pack() and Field_bit::unpack() assumes that the second argument is field->ptr.

Given Field_bit::pack(char *to, char *from), the odd bits are read from the member variable 'bit_ptr' instead of from the null bytes of the 'from'-record (the record that 'from' points into).  Since 'bit_ptr' points into the 'ptr'-record (the record that the member variable 'ptr' points into), it means that the odd bits are read from the 'ptr'-record, while the remaining bits are read from the 'from'-record.

Similarly for Field_bit::unpack(char *to, char *from), but here the odd bits are written to the 'ptr'-record instead of the 'to'-record.

How to repeat:
Read the code for Field_bit::pack() and Field_bit::unpack()

Suggested fix:
Read/write the odd bits from/to the correct record.
[20 Mar 2007 13:13] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/22341

ChangeSet@1.2478, 2007-03-20 14:13:07+01:00, mats@romeo.(none) +2 -0
  BUG#26969:
    Field_bit::pack() and Field_bit::unpack() does not work correctly
  
  Fixing code for Field_bit packing and unpacking to work with arbitrary
  pointers instead of requiring Field::ptr
[27 Mar 2007 15:30] Mats Kindahl
There is no documentation needed especially for this patch.
[31 Mar 2007 23:55] Bugs System
Pushed into 5.1.18-beta
[4 Apr 2007 3:26] Paul DuBois
No changelog entry needed.
[4 Apr 2007 3:26] Paul DuBois
No changelog entry needed.