[MDEV-15619] using CONVERT() inside AES_ENCRYPT() in an UPDATE corrupts data Created: 2018-03-21 Updated: 2020-08-25 Resolved: 2018-03-26 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Update |
| Affects Version/s: | 10.0, 10.1, 10.0.32, 10.1.31, 10.2.13, 10.2, 10.3 |
| Fix Version/s: | 10.0.35, 10.1.33, 10.2.15, 10.3.6 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Rick Pizzi | Assignee: | Alexander Barkov |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Description |
|
Customer trying to do the following:
Table definition:
The above update saves corrupted data.
|
| Comments |
| Comment by Steven McDowall [ 2018-03-21 ] | |||||||||||
|
BTW – it USED to work in prior versions of the main versions: 10.1.16 OK 10.3.0 OK | |||||||||||
| Comment by Steven McDowall [ 2018-03-23 ] | |||||||||||
|
Are we sure it's AES_ENCRYPT that broke or CONVERT ?? I forgot | |||||||||||
| Comment by Rick Pizzi [ 2018-03-23 ] | |||||||||||
|
It's the combo of both it seems, and only when updating a row. | |||||||||||
| Comment by Rick Pizzi [ 2018-03-23 ] | |||||||||||
|
This problem appeared first in 10.0.32 and 10.1.25 | |||||||||||
| Comment by Steven McDowall [ 2018-03-23 ] | |||||||||||
|
MariaDB Engineers – can you find the common commit (one presumes) in those versions and come back with what the bug is – what got introduced, etc? Thanks | |||||||||||
| Comment by Elena Stepanova [ 2018-03-23 ] | |||||||||||
|
The problem was introduced by this commit:
| |||||||||||
| Comment by Alexander Barkov [ 2018-03-26 ] | |||||||||||
|
A smaller test case reproducing the problem:
If I change 800 to 700, it inserts non-NULL data. | |||||||||||
| Comment by Alexander Barkov [ 2018-03-26 ] | |||||||||||
|
Starting from 10.1, the problem is also repeatable with AES_DECRYPT():
| |||||||||||
| Comment by Alexander Barkov [ 2018-03-26 ] | |||||||||||
|
The problem is that Item_func_aes_encrypt::val_str() and Item_func_aes_decrypt::val_str() use str_value as a buffer internally. This is wrong. There should be a separate buffer to get args[0]->val_str(). |