mbedTLS: missing init and free fixed

This commit is contained in:
Sepalani 2016-06-25 17:12:06 +04:00
parent 1af3b51fa7
commit 99a741b4e2

View File

@ -41,13 +41,16 @@ CWII_IPC_HLE_Device_net_ssl::~CWII_IPC_HLE_Device_net_ssl()
if (ssl.active)
{
mbedtls_ssl_close_notify(&ssl.ctx);
mbedtls_ssl_session_free(&ssl.session);
mbedtls_ssl_free(&ssl.ctx);
mbedtls_ssl_config_free(&ssl.config);
mbedtls_x509_crt_free(&ssl.cacert);
mbedtls_x509_crt_free(&ssl.clicert);
mbedtls_ssl_session_free(&ssl.session);
mbedtls_ssl_free(&ssl.ctx);
mbedtls_ssl_config_free(&ssl.config);
mbedtls_ctr_drbg_free(&ssl.ctr_drbg);
mbedtls_entropy_free(&ssl.entropy);
ssl.hostname.clear();
ssl.active = false;
@ -163,13 +166,14 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
WII_SSL* ssl = &_SSL[sslID];
mbedtls_ssl_init(&ssl->ctx);
mbedtls_entropy_init(&ssl->entropy);
const char* pers = "dolphin-emu";
static constexpr const char* pers = "dolphin-emu";
mbedtls_ctr_drbg_init(&ssl->ctr_drbg);
int ret = mbedtls_ctr_drbg_seed(&ssl->ctr_drbg, mbedtls_entropy_func, &ssl->entropy,
(const unsigned char*)pers, strlen(pers));
if (ret)
{
mbedtls_ssl_free(&ssl->ctx);
mbedtls_ctr_drbg_free(&ssl->ctr_drbg);
mbedtls_entropy_free(&ssl->entropy);
goto _SSL_NEW_ERROR;
}
@ -218,16 +222,18 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
if (SSLID_VALID(sslID))
{
WII_SSL* ssl = &_SSL[sslID];
mbedtls_ssl_close_notify(&ssl->ctx);
mbedtls_ssl_session_free(&ssl->session);
mbedtls_ssl_free(&ssl->ctx);
mbedtls_ssl_config_free(&ssl->config);
mbedtls_entropy_free(&ssl->entropy);
mbedtls_ssl_close_notify(&ssl->ctx);
mbedtls_x509_crt_free(&ssl->cacert);
mbedtls_x509_crt_free(&ssl->clicert);
mbedtls_ssl_session_free(&ssl->session);
mbedtls_ssl_free(&ssl->ctx);
mbedtls_ssl_config_free(&ssl->config);
mbedtls_ctr_drbg_free(&ssl->ctr_drbg);
mbedtls_entropy_free(&ssl->entropy);
ssl->hostname.clear();
ssl->active = false;