After objects have been freed, NULLify the pointers so there will be no double
[openssl.git] / crypto / x509 / x509_vfy.c
index d58f90010b20ac6a8242c274ba33415eb27252a3..ba2c3836f5b69558978b8a387bc402b36d7d5190 100644 (file)
@@ -81,7 +81,7 @@ static int check_policy(X509_STORE_CTX *ctx);
 static int crl_akid_check(X509_STORE_CTX *ctx, AUTHORITY_KEYID *akid);
 static int idp_check_scope(X509 *x, X509_CRL *crl);
 static int internal_verify(X509_STORE_CTX *ctx);
-const char *X509_version="X.509" OPENSSL_VERSION_PTEXT;
+const char X509_version[]="X.509" OPENSSL_VERSION_PTEXT;
 
 
 static int null_callback(int ok, X509_STORE_CTX *e)
@@ -314,7 +314,7 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
                ok=internal_verify(ctx);
        if(!ok) goto end;
 
-#ifdef OPENSSL_RFC3779
+#ifndef OPENSSL_NO_RFC3779
        /* RFC 3779 path validation, now that CRL check has been done */
        ok = v3_asid_validate_path(ctx);
        if (!ok) goto end;
@@ -1157,12 +1157,12 @@ end:
        return ok;
        }
 
-int X509_cmp_current_time(ASN1_TIME *ctm)
+int X509_cmp_current_time(const ASN1_TIME *ctm)
 {
        return X509_cmp_time(ctm, NULL);
 }
 
-int X509_cmp_time(ASN1_TIME *ctm, time_t *cmp_time)
+int X509_cmp_time(const ASN1_TIME *ctm, time_t *cmp_time)
        {
        char *str;
        ASN1_TIME atm;
@@ -1598,9 +1598,16 @@ void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk)
 void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx)
        {
        if (ctx->cleanup) ctx->cleanup(ctx);
-       X509_VERIFY_PARAM_free(ctx->param);
-       if (ctx->tree)
+       if (ctx->param != NULL)
+               {
+               X509_VERIFY_PARAM_free(ctx->param);
+               ctx->param=NULL;
+               }
+       if (ctx->tree != NULL)
+               {
                X509_policy_tree_free(ctx->tree);
+               ctx->tree=NULL;
+               }
        if (ctx->chain != NULL)
                {
                sk_X509_pop_free(ctx->chain,X509_free);