/* read in new CRL entries and save new list */ static int SwapLists(CYASSL_CRL* crl) { int ret; CYASSL_CRL tmp; CRL_Entry* newList; if (InitCRL(&tmp, crl->cm) < 0) { CYASSL_MSG("Init tmp CRL failed"); return -1; } if (crl->monitors[0].path) { 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, 0); return -1; } } if (crl->monitors[1].path) { 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, 0); return -1; } } if (LockMutex(&crl->crlLock) != 0) { CYASSL_MSG("LockMutex failed"); FreeCRL(&tmp, 0); return -1; } newList = tmp.crlList; /* swap lists */ tmp.crlList = crl->crlList; crl->crlList = newList; UnLockMutex(&crl->crlLock); FreeCRL(&tmp, 0); return 0; }
/* read in new CRL entries and save new list */ static int SwapLists(WOLFSSL_CRL* crl) { int ret; CRL_Entry* newList; #ifdef WOLFSSL_SMALL_STACK WOLFSSL_CRL* tmp; #else WOLFSSL_CRL tmp[1]; #endif #ifdef WOLFSSL_SMALL_STACK tmp = (WOLFSSL_CRL*)XMALLOC(sizeof(WOLFSSL_CRL), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (tmp == NULL) return MEMORY_E; #endif if (InitCRL(tmp, crl->cm) < 0) { WOLFSSL_MSG("Init tmp CRL failed"); #ifdef WOLFSSL_SMALL_STACK XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return -1; } if (crl->monitors[0].path) { ret = LoadCRL(tmp, crl->monitors[0].path, SSL_FILETYPE_PEM, 0); if (ret != SSL_SUCCESS) { WOLFSSL_MSG("PEM LoadCRL on dir change failed"); FreeCRL(tmp, 0); #ifdef WOLFSSL_SMALL_STACK XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return -1; } } if (crl->monitors[1].path) { ret = LoadCRL(tmp, crl->monitors[1].path, SSL_FILETYPE_ASN1, 0); if (ret != SSL_SUCCESS) { WOLFSSL_MSG("DER LoadCRL on dir change failed"); FreeCRL(tmp, 0); #ifdef WOLFSSL_SMALL_STACK XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return -1; } } if (LockMutex(&crl->crlLock) != 0) { WOLFSSL_MSG("LockMutex failed"); FreeCRL(tmp, 0); #ifdef WOLFSSL_SMALL_STACK XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return -1; } newList = tmp->crlList; /* swap lists */ tmp->crlList = crl->crlList; crl->crlList = newList; UnLockMutex(&crl->crlLock); FreeCRL(tmp, 0); #ifdef WOLFSSL_SMALL_STACK XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return 0; }