1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-08 14:02:17 +03:00

Fix for CONC-740:

Moved the initialization of server verification callback from
mysql_init to mysql_real_connect to avoid memory leak in case
of a reconnect.
This commit is contained in:
Georg Richter
2024-11-05 12:51:51 +01:00
parent efb0d9ac8b
commit 000ed6281f

View File

@@ -1317,7 +1317,6 @@ mysql_init(MYSQL *mysql)
mysql->extension->auto_local_infile= ENABLED_LOCAL_INFILE == LOCAL_INFILE_MODE_AUTO mysql->extension->auto_local_infile= ENABLED_LOCAL_INFILE == LOCAL_INFILE_MODE_AUTO
? WAIT_FOR_QUERY : ALWAYS_ACCEPT; ? WAIT_FOR_QUERY : ALWAYS_ACCEPT;
mysql->options.reconnect= 0; mysql->options.reconnect= 0;
mysql_optionsv(mysql, MARIADB_OPT_TLS_VERIFICATION_CALLBACK, ma_pvio_tls_verify_server_cert);
return mysql; return mysql;
error: error:
if (mysql->free_me) if (mysql->free_me)
@@ -1447,6 +1446,9 @@ mysql_real_connect(MYSQL *mysql, const char *host, const char *user,
char *connection_handler= (mysql->options.extension) ? char *connection_handler= (mysql->options.extension) ?
mysql->options.extension->connection_handler : 0; mysql->options.extension->connection_handler : 0;
if (!mysql->options.extension || !mysql->options.extension->tls_verification_callback)
mysql_optionsv(mysql, MARIADB_OPT_TLS_VERIFICATION_CALLBACK, ma_pvio_tls_verify_server_cert);
if ((client_flag & CLIENT_ALLOWED_FLAGS) != client_flag) if ((client_flag & CLIENT_ALLOWED_FLAGS) != client_flag)
{ {
my_set_error(mysql, CR_INVALID_CLIENT_FLAG, SQLSTATE_UNKNOWN, my_set_error(mysql, CR_INVALID_CLIENT_FLAG, SQLSTATE_UNKNOWN,