[CONC-345] heap-use-after-free in client_mpvio_read_packet Created: 2018-07-02 Updated: 2021-05-07 Resolved: 2021-05-07 |
|
| Status: | Closed |
| Project: | MariaDB Connector/C |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 3.0.7 |
| Type: | Bug | Priority: | Major |
| Reporter: | Marko Mäkelä | Assignee: | Georg Richter |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | ASAN, corruption | ||
| Environment: |
Debian GNU/Linux unstable |
||
| Issue Links: |
|
||||||||
| Description |
|
When compiling the code with clang 6.0 and cmake -DWITH_ASAN:BOOL=ON I got this error when running tests with
It looks like some error handling is wrong in Connector/C. The test is trying to misauthenticate:
It is the exec statement that fails. I wonder if this could explain |
| Comments |
| Comment by Marko Mäkelä [ 2018-08-22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I can still repeat the problem.
Note: I had to edit cmake/submodules.cmake to force the use of libmariadb v3.0.6:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2018-08-22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Note: When compiling with -O1 I got a wrong value pkt_len=0 displayed by gdb. With -O0 it made more sense:
With the following fix, it fails a little later:
It still fails on the same address as *buf:
The source line is:
For some reason, res==0 there, so the condition res > -1 will hold. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-01-25 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I do not see this failing with newer MariaDB server versions, but I do see the heap-use-after-free when testing the newest Connector/C library against the old MariaDB 10.2 server that I mentioned earlier:
Maybe, when run against a newer server, the handshake fails earlier, and the problematic code in Connector/C does not get executed. The problem appears to affect connections to older servers only. Here is the result from the above:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Kentoku Shiba (Inactive) [ 2019-07-02 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I assume this can be fixed like this. These error handling looks logically required.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Georg Richter [ 2021-05-07 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
this was already fixed by rev. 0f4891359a2f336698b4da1d2442a2a5e811435d |