[CONC-276] Crash after reconnecting to server using TLS Created: 2017-08-24 Updated: 2017-08-24 Resolved: 2017-08-24 |
|
| Status: | Closed |
| Project: | MariaDB Connector/C |
| Component/s: | None |
| Affects Version/s: | 3.0.2 |
| Fix Version/s: | 3.0.3 |
| Type: | Bug | Priority: | Major |
| Reporter: | Scott Thomas | Assignee: | Georg Richter |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Tested on Windows client with Linux server configured for TLS |
||
| Description |
|
Hi I'm seeing a crash within the MariaDB connector client when connecting to a server via TLS after a server reconnect (eg, internet, restart, etc). After doing some digging, it appears that the mysql pointer within the security context is not set to the new structure after a disconnect and reconnect, thus when doing a read or write the connector then tries to access freed memory. The crashes tend to happen deep inside ma_schannel_read_decrypt or ma_schannel_write_encrypt but can be traced back to ma_tls_read/write, (schannel.c, Ln 394 + Ln 408) where the sctx->mysql pointer refers to the pre-reconnect structure. Adding a hack to set sctx->mysql to ctls->pvio->mysql (or amending the following line to pvio = ctls->pvio) works however this is obviously not the correct location to update that pointer.
|
| Comments |
| Comment by Georg Richter [ 2017-08-24 ] | |
|
Thank you for reporting this bug which has been fixed now. One note about your test case: Since C/C 3.0 it's not mandatory to restart the server for emulating reconnect scenario - instead of you can use
API function to force a reconnect. commit a2b0bcda07c310aea63d90a17ea594c3c28ee93e |