Bug #63969 Out of bounds COMPRESS results in broken data
Submitted: 9 Jan 2012 16:56 Modified: 9 Feb 2012 19:42
Reporter: Ben Vaughn Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Errors Severity:S3 (Non-critical)
Version:5.1.60 OS:Any
Assigned to: CPU Architecture:Any

[9 Jan 2012 16:56] Ben Vaughn
Description:
In a table with a field defined as BLOB (tiny, regular, medium, huge, etc) INSERTing data into that blob that is larger than the field definition results in limited success -- information up to the character limit is stored and anything after the character limit is lost.

However, if you are using a text preparation function such as COMPRESS() and the results of that function are larger than the field size, no error is fired and the resulting field is unreadable and lost.

This could be particularly bad for a text preparation function like AES_ENCRYPT.

How to repeat:
Create a test table with a TINYBLOB, insert a record into that table with the TINYBLOB being COMPRESS()'d data larger than 255 characters.  Results of that will be unable to be read due to ZLIB corruption.

Suggested fix:
Do not permit INSERT that is larger than a defined field size when using text preparation functions like AES_ENCRYPT or COMPRESS
[9 Jan 2012 19:42] MySQL Verification Team
does sql_mode='strict_all_tables' cause an error to be raised when the data doesn't fit?
[10 Feb 2012 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".