Fix crashed issue if you call X509_free() after X509_STOER_CTX_free()

This commit is contained in:
Go Hosohara
2018-07-19 10:54:45 +09:00
parent 5de7a34fd4
commit 2669b80943
2 changed files with 7 additions and 9 deletions

View File

@@ -18474,12 +18474,6 @@ int wolfSSL_X509_STORE_CTX_init(WOLFSSL_X509_STORE_CTX* ctx,
void wolfSSL_X509_STORE_CTX_free(WOLFSSL_X509_STORE_CTX* ctx)
{
if (ctx != NULL) {
if (ctx->store != NULL)
wolfSSL_X509_STORE_free(ctx->store);
if (ctx->current_cert != NULL)
wolfSSL_FreeX509(ctx->current_cert);
if (ctx->chain != NULL)
wolfSSL_sk_X509_free(ctx->chain);
#ifdef OPENSSL_EXTRA
if (ctx->param != NULL){
XFREE(ctx->param,NULL,DYNAMIC_TYPE_OPENSSL);

View File

@@ -17259,6 +17259,8 @@ static void test_wolfSSL_X509_STORE_CTX(void)
X509_STORE_CTX_set_error(NULL, -5);
X509_STORE_CTX_free(ctx);
X509_STORE_free(str);
X509_free(x509);
AssertNotNull(ctx = X509_STORE_CTX_new());
X509_STORE_CTX_set_verify_cb(ctx, (void *)verify_cb);
@@ -18273,6 +18275,8 @@ static void test_wolfSSL_X509(void)
X509_STORE_CTX_free(ctx);
X509_STORE_free(store);
X509_free(x509);
BIO_free(bio);
/** d2i_X509_fp test **/
@@ -18499,7 +18503,7 @@ static void test_wolfSSL_HMAC(void)
static void test_wolfSSL_OBJ(void)
{
#if defined(OPENSSL_EXTRA) && !defined(NO_SHA256)
#if defined(OPENSSL_EXTRA) && !defined(NO_SHA256) && !defined(NO_ASN)
ASN1_OBJECT *obj = NULL;
char buf[50];
@@ -18560,7 +18564,7 @@ static void test_wolfSSL_OBJ(void)
AssertNotNull(asn1Name = X509_NAME_ENTRY_get_object(x509NameEntry));
AssertTrue((nid = OBJ_obj2nid(asn1Name)) > 0);
printf("nid=%d\n", nid);
ASN1_OBJECT_free(asn1Name);
//ASN1_OBJECT_free(asn1Name);
}
BIO_free(bio);
X509_free(x509);
@@ -18582,7 +18586,7 @@ static void test_wolfSSL_OBJ(void)
AssertNotNull(asn1Name = X509_NAME_ENTRY_get_object(x509NameEntry));
AssertTrue((nid = OBJ_obj2nid(asn1Name)) > 0);
printf("nid=%d\n", nid);
ASN1_OBJECT_free(asn1Name);
//ASN1_OBJECT_free(asn1Name);
}
BIO_free(bio);
X509_free(x509);