mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 20:24:39 +02:00
fix hash hrbg memory leaks
This commit is contained in:
@@ -1442,7 +1442,7 @@ int PKCS7_EncodeEnvelopedData(PKCS7* pkcs7, byte* output, word32 outputSz)
|
|||||||
XMEMCPY(output + idx, encryptedContent, desOutSz);
|
XMEMCPY(output + idx, encryptedContent, desOutSz);
|
||||||
idx += desOutSz;
|
idx += desOutSz;
|
||||||
|
|
||||||
#ifdef NO_RC4
|
#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
|
||||||
FreeRng(&rng);
|
FreeRng(&rng);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -4704,6 +4704,10 @@ int ecc_test(void)
|
|||||||
ecc_free(&userB);
|
ecc_free(&userB);
|
||||||
ecc_free(&userA);
|
ecc_free(&userA);
|
||||||
|
|
||||||
|
#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
|
||||||
|
FreeRng(&rng);
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5267,6 +5271,10 @@ int pkcs7signed_test(void)
|
|||||||
free(out);
|
free(out);
|
||||||
PKCS7_Free(&msg);
|
PKCS7_Free(&msg);
|
||||||
|
|
||||||
|
#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
|
||||||
|
FreeRng(&rng);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
11
src/ssl.c
11
src/ssl.c
@@ -10263,6 +10263,7 @@ int CyaSSL_RAND_seed(const void* seed, int len)
|
|||||||
int CyaSSL_RAND_bytes(unsigned char* buf, int num)
|
int CyaSSL_RAND_bytes(unsigned char* buf, int num)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
int initTmpRng = 0;
|
||||||
RNG* rng = NULL;
|
RNG* rng = NULL;
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
RNG* tmpRNG = NULL;
|
RNG* tmpRNG = NULL;
|
||||||
@@ -10278,8 +10279,10 @@ int CyaSSL_RAND_bytes(unsigned char* buf, int num)
|
|||||||
return ret;
|
return ret;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (InitRng(tmpRNG) == 0)
|
if (InitRng(tmpRNG) == 0) {
|
||||||
rng = tmpRNG;
|
rng = tmpRNG;
|
||||||
|
initTmpRng = 1;
|
||||||
|
}
|
||||||
else if (initGlobalRNG)
|
else if (initGlobalRNG)
|
||||||
rng = &globalRNG;
|
rng = &globalRNG;
|
||||||
|
|
||||||
@@ -10290,6 +10293,12 @@ int CyaSSL_RAND_bytes(unsigned char* buf, int num)
|
|||||||
ret = SSL_SUCCESS;
|
ret = SSL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (initTmpRng) {
|
||||||
|
#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
|
||||||
|
FreeRng(tmpRNG);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
XFREE(tmpRNG, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(tmpRNG, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user