]> granicus.if.org Git - openssl/commitdiff
Simplify X509_STORE_CTX_get1_chain (from master).
authorDr. Stephen Henson <steve@openssl.org>
Fri, 14 Feb 2014 13:33:43 +0000 (13:33 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Fri, 14 Feb 2014 15:12:52 +0000 (15:12 +0000)
crypto/x509/x509_vfy.c

index bcbf9ea55039672b6ab8d493469a52523d43cbca..990be83da36910b3f4e4b9ccab01824fa4a82cf3 100644 (file)
@@ -2123,16 +2123,9 @@ STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx)
 
 STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx)
        {
-       int i;
-       X509 *x;
-       STACK_OF(X509) *chain;
-       if (!ctx->chain || !(chain = sk_X509_dup(ctx->chain))) return NULL;
-       for (i = 0; i < sk_X509_num(chain); i++)
-               {
-               x = sk_X509_value(chain, i);
-               CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509);
-               }
-       return chain;
+       if (!ctx->chain)
+               return NULL;
+       return X509_chain_up_ref(ctx->chain);
        }
 
 X509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx)