[MDEV-5013] sql/sql_plugin.cc:update_func_str() for PLUGIN_VAR_MEMALLOC may cause double free Created: 2013-09-13 Updated: 2013-09-21 Resolved: 2013-09-21 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 10.0.4 |
| Fix Version/s: | 10.0.5 |
| Type: | Bug | Priority: | Major |
| Reporter: | Kouhei Sutou | Assignee: | Sergei Golubchik |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
My platform is Debian GNU/Linux sid x86_64 but it causes all platform. |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Description |
|
If there is the following variable definition, it may cause double free:
The points are PLUGIN_VAR_MEMALLOC and the default update function. If this pattern is used, the following SQL causes double free:
If a variable uses PLUGIN_VAR_MEMALLOC and the default update function, the following code is used in sql/sql_plugin.cc:
if value is NULL, tgt still referes freed memory. It is freed in sql/sql_plugin.cc:plugin_vars_free_values(). It causes double free. This pattern isn't used all of bundled storage engines. It is used in mroonga storage engine: https://github.com/mroonga/mroonga/blob/3156280442792c1446175044ba666428690b9c55/ha_mroonga.cpp#L699 I will attach a patch to fix the problem. |
| Comments |
| Comment by Sergei Golubchik [ 2013-09-13 ] |
|
Yes, thanks! |
| Comment by Kouhei Sutou [ 2013-09-14 ] |
|
Thanks for confirming it! I'll wait for the next release! (Thanks for fixing markup of the description. |