fix crl resource leaks
This commit is contained in:
parent
f5590f0abd
commit
faa7283ff3
@ -33,7 +33,7 @@
|
||||
typedef struct CYASSL_CRL CYASSL_CRL;
|
||||
|
||||
CYASSL_LOCAL int InitCRL(CYASSL_CRL*, CYASSL_CERT_MANAGER*);
|
||||
CYASSL_LOCAL void FreeCRL(CYASSL_CRL*);
|
||||
CYASSL_LOCAL void FreeCRL(CYASSL_CRL*, int dynamic);
|
||||
|
||||
CYASSL_LOCAL int LoadCRL(CYASSL_CRL* crl, const char* path, int type, int mon);
|
||||
CYASSL_LOCAL int BufferLoadCRL(CYASSL_CRL*, const byte*, long, int);
|
||||
|
14
src/crl.c
14
src/crl.c
@ -90,7 +90,7 @@ static void FreeCRL_Entry(CRL_Entry* crle)
|
||||
|
||||
|
||||
/* Free all CRL resources */
|
||||
void FreeCRL(CYASSL_CRL* crl)
|
||||
void FreeCRL(CYASSL_CRL* crl, int dynamic)
|
||||
{
|
||||
CRL_Entry* tmp = crl->crlList;
|
||||
|
||||
@ -116,6 +116,8 @@ void FreeCRL(CYASSL_CRL* crl)
|
||||
}
|
||||
#endif
|
||||
FreeMutex(&crl->crlLock);
|
||||
if (dynamic) /* free self */
|
||||
XFREE(crl, NULL, DYNAMIC_TYPE_CRL);
|
||||
}
|
||||
|
||||
|
||||
@ -295,7 +297,7 @@ static int SwapLists(CYASSL_CRL* crl)
|
||||
ret = LoadCRL(&tmp, crl->monitors[0].path, SSL_FILETYPE_PEM, 0);
|
||||
if (ret != SSL_SUCCESS) {
|
||||
CYASSL_MSG("PEM LoadCRL on dir change failed");
|
||||
FreeCRL(&tmp);
|
||||
FreeCRL(&tmp, 0);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -304,14 +306,14 @@ static int SwapLists(CYASSL_CRL* crl)
|
||||
ret = LoadCRL(&tmp, crl->monitors[1].path, SSL_FILETYPE_ASN1, 0);
|
||||
if (ret != SSL_SUCCESS) {
|
||||
CYASSL_MSG("DER LoadCRL on dir change failed");
|
||||
FreeCRL(&tmp);
|
||||
FreeCRL(&tmp, 0);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (LockMutex(&crl->crlLock) != 0) {
|
||||
CYASSL_MSG("LockMutex failed");
|
||||
FreeCRL(&tmp);
|
||||
FreeCRL(&tmp, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -323,7 +325,7 @@ static int SwapLists(CYASSL_CRL* crl)
|
||||
|
||||
UnLockMutex(&crl->crlLock);
|
||||
|
||||
FreeCRL(&tmp);
|
||||
FreeCRL(&tmp, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -581,6 +583,8 @@ int LoadCRL(CYASSL_CRL* crl, const char* path, int type, int monitor)
|
||||
ret = StartMonitorCRL(crl);
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -592,7 +592,7 @@ void CyaSSL_CertManagerFree(CYASSL_CERT_MANAGER* cm)
|
||||
if (cm) {
|
||||
#ifdef HAVE_CRL
|
||||
if (cm->crl)
|
||||
FreeCRL(cm->crl);
|
||||
FreeCRL(cm->crl, 1);
|
||||
#endif
|
||||
FreeSigners(cm->caList, NULL);
|
||||
FreeMutex(&cm->caLock);
|
||||
@ -1716,7 +1716,7 @@ int CyaSSL_CertManagerEnableCRL(CYASSL_CERT_MANAGER* cm, int options)
|
||||
|
||||
if (InitCRL(cm->crl, cm) != 0) {
|
||||
CYASSL_MSG("Init CRL failed");
|
||||
FreeCRL(cm->crl);
|
||||
FreeCRL(cm->crl, 1);
|
||||
cm->crl = NULL;
|
||||
return SSL_FAILURE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user