[MDEV-29644] a potential bug of null pointer dereference in spider_db_mbase::print_warnings() Created: 2022-09-27 Updated: 2023-05-12 Resolved: 2023-02-03 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - Spider |
| Affects Version/s: | 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11 |
| Fix Version/s: | 10.11.3, 10.3.39, 10.4.29, 10.5.20, 10.6.13, 10.8.8, 10.9.6, 10.10.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | ash1852 | Assignee: | Yuchen Pei |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
ubuntu20.04 |
||
| Attachments: |
|
||||
| Issue Links: |
|
||||
| Description |
| Comments |
| Comment by Daniel Black [ 2022-09-27 ] | ||
|
mysql_store_result seems to say NULL is returned for errors (which is handled correctly, or 0 results like INSERT/ UPDATE). spider_db_mbase::exec_query where print_warnings seems to take an update, so looks valid. | ||
| Comment by ash1852 [ 2022-09-27 ] | ||
|
I don't understand your mean.as you say,"mysql_store_result seems to say NULL is returned for errors".by looking at the source code of the mysql_store_result function, it can be seen that not all return null site will set errno to a non-zero value.So it is possible that the res ptr in the figure is null while errno is 0, so that the function print_warning does not return at line 2205,and dereference of null pointer res will occur at line 2209 in the graph. | ||
| Comment by Nayuta Yanagisawa (Inactive) [ 2022-09-28 ] | ||
|
ash1852 Thank you for the report. According to the implementation, the above-mentioned null pointer dereference seems to be logically possible while it wouldn't be easy to find a test case that actually causes the null pointer dereference. | ||
| Comment by Nayuta Yanagisawa (Inactive) [ 2022-09-29 ] | ||
|
holyfoot Please review: https://github.com/MariaDB/server/commit/be0a46b3d52b58956fd0d47d040b9f4514406954 | ||
| Comment by Alexey Botchkov [ 2022-10-11 ] | ||
|
ok to push. | ||
| Comment by Yuchen Pei [ 2023-02-02 ] | ||
|
| ||
| Comment by Yuchen Pei [ 2023-02-02 ] | ||
|
I made some minor changes to the test case so that it passes 10.4. Can you take a look holyfoot? Thank you. https://github.com/MariaDB/server/commit/d346bd3ab03 | ||
| Comment by Alexey Botchkov [ 2023-02-02 ] | ||
|
see comment at the patch. | ||
| Comment by Yuchen Pei [ 2023-02-03 ] | ||
|
Thanks for the comments and review, holyfoot. The comments were incorporated and patch pushed to 10.3. Some merge conflicts needed to be handled, and below are patches for all versions:
|