diff options
-rw-r--r-- | client/mysql.cc | 6 | ||||
-rw-r--r-- | include/mysql.h | 3 | ||||
-rw-r--r-- | libmysql/libmysql.c | 29 | ||||
-rw-r--r-- | sql/mysqld.cc | 2 |
4 files changed, 20 insertions, 20 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index 8ae4c9df8cd..436675ebc15 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -377,6 +377,9 @@ sig_handler mysql_end(int sig) { if (connected) mysql_close(&mysql); + else + mysql_ssl_clear(&mysql); /* SSL data structres should be freed + even if connection was not made */ #ifdef HAVE_READLINE if (!status.batch && !quick && !opt_html && !opt_xml) { @@ -2204,6 +2207,9 @@ sql_real_connect(char *host,char *database,char *user,char *password, mysql_close(&mysql); connected= 0; } + else + mysql_ssl_clear(&mysql); /* SSL data structres should be freed + even if connection was not made */ mysql_init(&mysql); if (opt_connect_timeout) { diff --git a/include/mysql.h b/include/mysql.h index 9578336a945..7db907fb0f3 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -256,13 +256,10 @@ unsigned long STDCALL mysql_thread_id(MYSQL *mysql); const char * STDCALL mysql_character_set_name(MYSQL *mysql); MYSQL * STDCALL mysql_init(MYSQL *mysql); -#ifdef HAVE_OPENSSL int STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert, const char *ca, const char *capath); -char * STDCALL mysql_ssl_cipher(MYSQL *mysql); int STDCALL mysql_ssl_clear(MYSQL *mysql); -#endif /* HAVE_OPENSSL */ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, const char *passwd, const char *db); MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index a23fa732fb6..a59100903db 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1359,16 +1359,19 @@ static void mysql_once_init() #endif } -#ifdef HAVE_OPENSSL /************************************************************************** ** Fill in SSL part of MYSQL structure and set 'use_ssl' flag. ** NB! Errors are not reported until you do mysql_real_connect. **************************************************************************/ int STDCALL -mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert, - const char *ca, const char *capath) +mysql_ssl_set(MYSQL *mysql __attribute__((unused)) , + const char *key __attribute__((unused)), + const char *cert __attribute__((unused)), + const char *ca __attribute__((unused)), + const char *capath __attribute__((unused))) { +#ifdef HAVE_OPENSSL mysql->options.ssl_key = key==0 ? 0 : my_strdup(key,MYF(0)); mysql->options.ssl_cert = cert==0 ? 0 : my_strdup(cert,MYF(0)); mysql->options.ssl_ca = ca==0 ? 0 : my_strdup(ca,MYF(0)); @@ -1376,28 +1379,20 @@ mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert, mysql->options.use_ssl = TRUE; mysql->connector_fd = (gptr)new_VioSSLConnectorFd(key, cert, ca, capath); DBUG_PRINT("info",("mysql_ssl_set, context: %p",((struct st_VioSSLConnectorFd *)(mysql->connector_fd))->ssl_context_)); - +#endif return 0; } -/************************************************************************** -************************************************************************** - -char * STDCALL -mysql_ssl_cipher(MYSQL *mysql) -{ - return (char *)mysql->net.vio->cipher_description(); -} - - -************************************************************************** +/* +*************************************************************************** ** Free strings in the SSL structure and clear 'use_ssl' flag. ** NB! Errors are not reported until you do mysql_real_connect. ************************************************************************** */ int STDCALL -mysql_ssl_clear(MYSQL *mysql) +mysql_ssl_clear(MYSQL *mysql __attribute__((unused))) { +#ifdef HAVE_OPENSSL my_free(mysql->options.ssl_key, MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->options.ssl_cert, MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->options.ssl_ca, MYF(MY_ALLOW_ZERO_PTR)); @@ -1409,9 +1404,9 @@ mysql_ssl_clear(MYSQL *mysql) mysql->options.use_ssl = FALSE; my_free(mysql->connector_fd,MYF(MY_ALLOW_ZERO_PTR)); mysql->connector_fd = 0; +#endif /* HAVE_OPENSSL */ return 0; } -#endif /* HAVE_OPENSSL */ /************************************************************************** ** Connect to sql server diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8f91cbc70b1..17f201dfbc8 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1991,7 +1991,9 @@ The server will not act as a slave."); if(hEventShutdown) CloseHandle(hEventShutdown); } #endif +#ifdef HAVE_OPENSSL my_free((gptr)ssl_acceptor_fd,MYF(0)); +#endif /* HAVE_OPENSSL */ /* Wait until cleanup is done */ (void) pthread_mutex_lock(&LOCK_thread_count); while (!ready_to_exit) |