Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
-
None
-
Windows 10 x64 (build 19045), Schannel. Found with MariaDB Connector/ODBC 3.2.10 (64-bit, libmariadb submodule be67a4f), server MariaDB 12.3.4 on the same machine.
Description
Every successful TLS connect through the Schannel backend leaks the ClientHello buffer (about 250 bytes per connection).
Cause: libmariadb/secure/ma_schannel.c, ma_schannel_client_handshake(). InitializeSecurityContext (line 312, ISC_REQ_ALLOCATE_MEMORY) allocates the ClientHello in BuffersOut.pvBuffer. On success the function returns at line 356 ("return sRet;"), so FreeContextBuffer under "end:" (line 359) is only reached on the error paths.
Fix: remove line 356, so the success path falls through to "end:"
(sRet is SEC_E_OK there).
How to repeat (attached connleak.c, ODBC API only): SQLConnect / SQLDisconnect in a loop against a DSN of Connector/ODBC 3.2.10 with FORCETLS=1, private bytes every 1000 connects. Result: +259 bytes per connect, linear; flat without FORCETLS.
The attached schannel_hello.c (no server needed) repeats only the first InitializeSecurityContext with the flags of Connector/C: +265 bytes per iteration without FreeContextBuffer, flat with it.
Seen in Connector/ODBC 3.2.10 (libmariadb be67a4f); the code is the same on the 3.3 and 3.4 branches.