Skip to content

Commit

Permalink
free mysql->connector_fd correctly in the internal client
Browse files Browse the repository at this point in the history
it's not an ssl option, so shouldn't be in mysql_ssl_free(),
which frees ssl options, and only unless CLIENT_REMEMBER_OPTIONS is set.

mysql->connector_fd must be freed when mysql->net.vio is closed
and fd becomes no longer valid
  • Loading branch information
vuvova committed Feb 4, 2024
1 parent 2f13f7d commit 3c36ed1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions sql-common/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,12 @@ void end_server(MYSQL *mysql)
DBUG_ENTER("end_server");
if (mysql->net.vio != 0)
{
struct st_VioSSLFd *ssl_fd= (struct st_VioSSLFd*) mysql->connector_fd;
if (ssl_fd)
SSL_CTX_free(ssl_fd->ssl_context);
my_free(ssl_fd);
mysql->connector_fd = 0;

DBUG_PRINT("info",("Net: %s", vio_description(mysql->net.vio)));
#ifdef MYSQL_SERVER
slave_io_thread_detach_vio();
Expand Down Expand Up @@ -1509,7 +1515,6 @@ mysql_ssl_set(MYSQL *mysql __attribute__((unused)) ,
static void
mysql_ssl_free(MYSQL *mysql __attribute__((unused)))
{
struct st_VioSSLFd *ssl_fd= (struct st_VioSSLFd*) mysql->connector_fd;
DBUG_ENTER("mysql_ssl_free");

my_free(mysql->options.ssl_key);
Expand All @@ -1522,9 +1527,6 @@ mysql_ssl_free(MYSQL *mysql __attribute__((unused)))
my_free(mysql->options.extension->ssl_crl);
my_free(mysql->options.extension->ssl_crlpath);
}
if (ssl_fd)
SSL_CTX_free(ssl_fd->ssl_context);
my_free(mysql->connector_fd);
mysql->options.ssl_key = 0;
mysql->options.ssl_cert = 0;
mysql->options.ssl_ca = 0;
Expand All @@ -1536,7 +1538,6 @@ mysql_ssl_free(MYSQL *mysql __attribute__((unused)))
mysql->options.extension->ssl_crlpath = 0;
}
mysql->options.use_ssl = FALSE;
mysql->connector_fd = 0;
DBUG_VOID_RETURN;
}

Expand Down

0 comments on commit 3c36ed1

Please sign in to comment.