apps/x509.c:1004: error: MEMORY_LEAK
  memory dynamically allocated by call to `X509_STORE_CTX_new()` at line 953, column 11 is not reachable after line 1004, column 5.
Showing all 79 steps of the trace


apps/x509.c:934:1: start of procedure x509_certify()
932.   }
933.   
934. > static int x509_certify(X509_STORE *ctx, const char *CAfile, const EVP_MD *digest,
935.                           X509 *x, X509 *xca, EVP_PKEY *pkey,
936.                           STACK_OF(OPENSSL_STRING) *sigopts,

apps/x509.c:941:5: 
939.                           ASN1_INTEGER *sno, int reqfile)
940.   {
941. >     int ret = 0;
942.       ASN1_INTEGER *bs = NULL;
943.       X509_STORE_CTX *xsc = NULL;

apps/x509.c:942:5: 
940.   {
941.       int ret = 0;
942. >     ASN1_INTEGER *bs = NULL;
943.       X509_STORE_CTX *xsc = NULL;
944.       EVP_PKEY *upkey;

apps/x509.c:943:5: 
941.       int ret = 0;
942.       ASN1_INTEGER *bs = NULL;
943. >     X509_STORE_CTX *xsc = NULL;
944.       EVP_PKEY *upkey;
945.   

apps/x509.c:946:5: 
944.       EVP_PKEY *upkey;
945.   
946. >     upkey = X509_get0_pubkey(xca);
947.       if (upkey == NULL) {
948.           BIO_printf(bio_err, "Error obtaining CA X509 public key\n");

crypto/x509/x509_cmp.c:265:1: start of procedure X509_get0_pubkey()
  263.   }
  264.   
  265. > EVP_PKEY *X509_get0_pubkey(const X509 *x)
  266.   {
  267.       if (x == NULL)

crypto/x509/x509_cmp.c:267:9: Taking false branch
  265.   EVP_PKEY *X509_get0_pubkey(const X509 *x)
  266.   {
  267.       if (x == NULL)
                 ^
  268.           return NULL;
  269.       return X509_PUBKEY_get0(x->cert_info.key);

crypto/x509/x509_cmp.c:269:5: 
  267.       if (x == NULL)
  268.           return NULL;
  269. >     return X509_PUBKEY_get0(x->cert_info.key);
  270.   }
  271.   

crypto/x509/x_pubkey.c:140:1: start of procedure X509_PUBKEY_get0()
    138.   }
    139.   
    140. > EVP_PKEY *X509_PUBKEY_get0(X509_PUBKEY *key)
    141.   {
    142.       EVP_PKEY *ret = NULL;

crypto/x509/x_pubkey.c:142:5: 
    140.   EVP_PKEY *X509_PUBKEY_get0(X509_PUBKEY *key)
    141.   {
    142. >     EVP_PKEY *ret = NULL;
    143.   
    144.       if (key == NULL || key->public_key == NULL)

crypto/x509/x_pubkey.c:144:9: Taking false branch
    142.       EVP_PKEY *ret = NULL;
    143.   
    144.       if (key == NULL || key->public_key == NULL)
                   ^
    145.           return NULL;
    146.   

crypto/x509/x_pubkey.c:144:24: Taking false branch
    142.       EVP_PKEY *ret = NULL;
    143.   
    144.       if (key == NULL || key->public_key == NULL)
                                  ^
    145.           return NULL;
    146.   

crypto/x509/x_pubkey.c:147:9: Taking true branch
    145.           return NULL;
    146.   
    147.       if (key->pkey != NULL)
                   ^
    148.           return key->pkey;
    149.   

crypto/x509/x_pubkey.c:148:9: 
    146.   
    147.       if (key->pkey != NULL)
    148. >         return key->pkey;
    149.   
    150.       /*

crypto/x509/x_pubkey.c:166:1: return from a call to X509_PUBKEY_get0
    164.   
    165.       return NULL;
    166. > }
    167.   
    168.   EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)

crypto/x509/x509_cmp.c:270:1: return from a call to X509_get0_pubkey
  268.           return NULL;
  269.       return X509_PUBKEY_get0(x->cert_info.key);
  270. > }
  271.   
  272.   EVP_PKEY *X509_get_pubkey(X509 *x)

apps/x509.c:947:9: Taking false branch
945.   
946.       upkey = X509_get0_pubkey(xca);
947.       if (upkey == NULL) {
               ^
948.           BIO_printf(bio_err, "Error obtaining CA X509 public key\n");
949.           goto end;

apps/x509.c:951:5: 
949.           goto end;
950.       }
951. >     EVP_PKEY_copy_parameters(upkey, pkey);
952.   
953.       xsc = X509_STORE_CTX_new();

crypto/evp/p_lib.c:73:1: start of procedure EVP_PKEY_copy_parameters()
  71.   }
  72.   
  73. > int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from)
  74.   {
  75.       if (to->type == EVP_PKEY_NONE) {

crypto/evp/p_lib.c:75:9: Taking false branch
  73.   int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from)
  74.   {
  75.       if (to->type == EVP_PKEY_NONE) {
                ^
  76.           if (EVP_PKEY_set_type(to, from->type) == 0)
  77.               return 0;

crypto/evp/p_lib.c:78:16: Taking true branch
  76.           if (EVP_PKEY_set_type(to, from->type) == 0)
  77.               return 0;
  78.       } else if (to->type != from->type) {
                       ^
  79.           EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS, EVP_R_DIFFERENT_KEY_TYPES);
  80.           goto err;

crypto/evp/p_lib.c:79:9: Skipping ERR_put_error(): empty list of specs
  77.               return 0;
  78.       } else if (to->type != from->type) {
  79.           EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS, EVP_R_DIFFERENT_KEY_TYPES);
                ^
  80.           goto err;
  81.       }

crypto/evp/p_lib.c:97:2: 
  95.       if (from->ameth && from->ameth->param_copy)
  96.           return from->ameth->param_copy(to, from);
  97. >  err:
  98.       return 0;
  99.   }

crypto/evp/p_lib.c:98:5: 
  96.           return from->ameth->param_copy(to, from);
  97.    err:
  98. >     return 0;
  99.   }
  100.   

crypto/evp/p_lib.c:99:1: return from a call to EVP_PKEY_copy_parameters
  97.    err:
  98.       return 0;
  99. > }
  100.   
  101.   int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey)

apps/x509.c:953:5: 
951.       EVP_PKEY_copy_parameters(upkey, pkey);
952.   
953. >     xsc = X509_STORE_CTX_new();
954.       if (xsc == NULL || !X509_STORE_CTX_init(xsc, ctx, x, NULL)) {
955.           BIO_printf(bio_err, "Error initialising X509 store\n");

crypto/x509/x509_vfy.c:2150:1: start of procedure X509_STORE_CTX_new()
  2148.   }
  2149.   
  2150. > X509_STORE_CTX *X509_STORE_CTX_new(void)
  2151.   {
  2152.       X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));

crypto/x509/x509_vfy.c:2152:5: 
  2150.   X509_STORE_CTX *X509_STORE_CTX_new(void)
  2151.   {
  2152. >     X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  2153.   
  2154.       if (ctx == NULL) {

crypto/mem.c:186:1: start of procedure CRYPTO_zalloc()
    184.   }
    185.   
    186. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    187.   {
    188.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:188:5: 
    186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    187.   {
    188. >     void *ret = CRYPTO_malloc(num, file, line);
    189.   
    190.       FAILTEST();

crypto/mem.c:158:1: start of procedure CRYPTO_malloc()
      156.   #endif
      157.   
      158. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      159.   {
      160.       void *ret = NULL;

crypto/mem.c:160:5: 
      158.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      159.   {
      160. >     void *ret = NULL;
      161.   
      162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:162:9: Taking false branch
      160.       void *ret = NULL;
      161.   
      162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      163.           return malloc_impl(num, file, line);
      164.   

crypto/mem.c:165:9: Taking false branch
      163.           return malloc_impl(num, file, line);
      164.   
      165.       if (num == 0)
                     ^
      166.           return NULL;
      167.   

crypto/mem.c:169:5: 
      167.   
      168.       FAILTEST();
      169. >     allow_customize = 0;
      170.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      171.       if (call_malloc_debug) {

crypto/mem.c:179:5: 
      177.       }
      178.   #else
      179. >     osslargused(file); osslargused(line);
      180.       ret = malloc(num);
      181.   #endif

crypto/mem.c:179:24: 
      177.       }
      178.   #else
      179. >     osslargused(file); osslargused(line);
      180.       ret = malloc(num);
      181.   #endif

crypto/mem.c:180:5: 
      178.   #else
      179.       osslargused(file); osslargused(line);
      180. >     ret = malloc(num);
      181.   #endif
      182.   

crypto/mem.c:183:5: 
      181.   #endif
      182.   
      183. >     return ret;
      184.   }
      185.   

crypto/mem.c:184:1: return from a call to CRYPTO_malloc
      182.   
      183.       return ret;
      184. > }
      185.   
      186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:191:9: Taking true branch
    189.   
    190.       FAILTEST();
    191.       if (ret != NULL)
                   ^
    192.           memset(ret, 0, num);
    193.       return ret;

crypto/mem.c:192:9: 
    190.       FAILTEST();
    191.       if (ret != NULL)
    192. >         memset(ret, 0, num);
    193.       return ret;
    194.   }

crypto/mem.c:193:5: 
    191.       if (ret != NULL)
    192.           memset(ret, 0, num);
    193. >     return ret;
    194.   }
    195.   

crypto/mem.c:194:1: return from a call to CRYPTO_zalloc
    192.           memset(ret, 0, num);
    193.       return ret;
    194. > }
    195.   
    196.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/x509/x509_vfy.c:2154:9: Taking false branch
  2152.       X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  2153.   
  2154.       if (ctx == NULL) {
                  ^
  2155.           X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE);
  2156.           return NULL;

crypto/x509/x509_vfy.c:2158:5: 
  2156.           return NULL;
  2157.       }
  2158. >     return ctx;
  2159.   }
  2160.   

crypto/x509/x509_vfy.c:2159:1: return from a call to X509_STORE_CTX_new
  2157.       }
  2158.       return ctx;
  2159. > }
  2160.   
  2161.   void X509_STORE_CTX_free(X509_STORE_CTX *ctx)

apps/x509.c:954:9: Taking false branch
952.   
953.       xsc = X509_STORE_CTX_new();
954.       if (xsc == NULL || !X509_STORE_CTX_init(xsc, ctx, x, NULL)) {
               ^
955.           BIO_printf(bio_err, "Error initialising X509 store\n");
956.           goto end;

apps/x509.c:954:25: Taking false branch
952.   
953.       xsc = X509_STORE_CTX_new();
954.       if (xsc == NULL || !X509_STORE_CTX_init(xsc, ctx, x, NULL)) {
                               ^
955.           BIO_printf(bio_err, "Error initialising X509 store\n");
956.           goto end;

apps/x509.c:958:9: Taking true branch
956.           goto end;
957.       }
958.       if (sno)
               ^
959.           bs = sno;
960.       else if ((bs = x509_load_serial(CAfile, serialfile, create)) == NULL)

apps/x509.c:959:9: 
957.       }
958.       if (sno)
959. >         bs = sno;
960.       else if ((bs = x509_load_serial(CAfile, serialfile, create)) == NULL)
961.           goto end;

apps/x509.c:967:5: 
965.        * certificate request in which case it is not.
966.        */
967. >     X509_STORE_CTX_set_cert(xsc, x);
968.       X509_STORE_CTX_set_flags(xsc, X509_V_FLAG_CHECK_SS_SIGNATURE);
969.       if (!reqfile && X509_verify_cert(xsc) <= 0)

crypto/x509/x509_vfy.c:2059:1: start of procedure X509_STORE_CTX_set_cert()
  2057.   }
  2058.   
  2059. > void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *x)
  2060.   {
  2061.       ctx->cert = x;

crypto/x509/x509_vfy.c:2061:5: 
  2059.   void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *x)
  2060.   {
  2061. >     ctx->cert = x;
  2062.   }
  2063.   

crypto/x509/x509_vfy.c:2062:1: return from a call to X509_STORE_CTX_set_cert
  2060.   {
  2061.       ctx->cert = x;
  2062. > }
  2063.   
  2064.   void X509_STORE_CTX_set0_crls(X509_STORE_CTX *ctx, STACK_OF(X509_CRL) *sk)

apps/x509.c:968:5: 
966.        */
967.       X509_STORE_CTX_set_cert(xsc, x);
968. >     X509_STORE_CTX_set_flags(xsc, X509_V_FLAG_CHECK_SS_SIGNATURE);
969.       if (!reqfile && X509_verify_cert(xsc) <= 0)
970.           goto end;

crypto/x509/x509_vfy.c:2350:1: start of procedure X509_STORE_CTX_set_flags()
  2348.   }
  2349.   
  2350. > void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags)
  2351.   {
  2352.       X509_VERIFY_PARAM_set_flags(ctx->param, flags);

crypto/x509/x509_vfy.c:2352:5: 
  2350.   void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags)
  2351.   {
  2352. >     X509_VERIFY_PARAM_set_flags(ctx->param, flags);
  2353.   }
  2354.   

crypto/x509/x509_vpm.c:272:1: start of procedure X509_VERIFY_PARAM_set_flags()
    270.   }
    271.   
    272. > int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags)
    273.   {
    274.       param->flags |= flags;

crypto/x509/x509_vpm.c:274:5: 
    272.   int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags)
    273.   {
    274. >     param->flags |= flags;
    275.       if (flags & X509_V_FLAG_POLICY_MASK)
    276.           param->flags |= X509_V_FLAG_POLICY_CHECK;

crypto/x509/x509_vpm.c:275:9: Taking false branch
    273.   {
    274.       param->flags |= flags;
    275.       if (flags & X509_V_FLAG_POLICY_MASK)
                   ^
    276.           param->flags |= X509_V_FLAG_POLICY_CHECK;
    277.       return 1;

crypto/x509/x509_vpm.c:277:5: 
    275.       if (flags & X509_V_FLAG_POLICY_MASK)
    276.           param->flags |= X509_V_FLAG_POLICY_CHECK;
    277. >     return 1;
    278.   }
    279.   

crypto/x509/x509_vpm.c:278:1: return from a call to X509_VERIFY_PARAM_set_flags
    276.           param->flags |= X509_V_FLAG_POLICY_CHECK;
    277.       return 1;
    278. > }
    279.   
    280.   int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param,

crypto/x509/x509_vfy.c:2353:1: return from a call to X509_STORE_CTX_set_flags
  2351.   {
  2352.       X509_VERIFY_PARAM_set_flags(ctx->param, flags);
  2353. > }
  2354.   
  2355.   void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,

apps/x509.c:969:10: Taking true branch
967.       X509_STORE_CTX_set_cert(xsc, x);
968.       X509_STORE_CTX_set_flags(xsc, X509_V_FLAG_CHECK_SS_SIGNATURE);
969.       if (!reqfile && X509_verify_cert(xsc) <= 0)
                ^
970.           goto end;
971.   

apps/x509.c:969:21: Taking true branch
967.       X509_STORE_CTX_set_cert(xsc, x);
968.       X509_STORE_CTX_set_flags(xsc, X509_V_FLAG_CHECK_SS_SIGNATURE);
969.       if (!reqfile && X509_verify_cert(xsc) <= 0)
                           ^
970.           goto end;
971.   

apps/x509.c:1003:2: 
1001.           goto end;
1002.       ret = 1;
1003. >  end:
1004.       X509_STORE_CTX_free(xsc);
1005.       if (!ret)

apps/x509.c:1004:5: 
1002.       ret = 1;
1003.    end:
1004. >     X509_STORE_CTX_free(xsc);
1005.       if (!ret)
1006.           ERR_print_errors(bio_err);

crypto/x509/x509_vfy.c:2161:1: start of procedure X509_STORE_CTX_free()
  2159.   }
  2160.   
  2161. > void X509_STORE_CTX_free(X509_STORE_CTX *ctx)
  2162.   {
  2163.       if (ctx == NULL)

crypto/x509/x509_vfy.c:2163:9: Taking false branch
  2161.   void X509_STORE_CTX_free(X509_STORE_CTX *ctx)
  2162.   {
  2163.       if (ctx == NULL)
                  ^
  2164.           return;
  2165.   

crypto/x509/x509_vfy.c:2166:5: Skipping X509_STORE_CTX_cleanup(): empty list of specs
  2164.           return;
  2165.   
  2166.       X509_STORE_CTX_cleanup(ctx);
              ^
  2167.       OPENSSL_free(ctx);
  2168.   }

crypto/x509/x509_vfy.c:2167:5: 
  2165.   
  2166.       X509_STORE_CTX_cleanup(ctx);
  2167. >     OPENSSL_free(ctx);
  2168.   }
  2169.   

crypto/mem.c:253:1: start of procedure CRYPTO_free()
    251.   }
    252.   
    253. > void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:255:9: Taking true branch
    253.   void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    256.           free_impl(str, file, line);
    257.           return;

crypto/mem.c:255:30: Taking true branch
    253.   void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    256.           free_impl(str, file, line);
    257.           return;

crypto/mem.c:256:9: Skipping __function_pointer__(): unresolved function pointer
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    256.           free_impl(str, file, line);
                   ^
    257.           return;
    258.       }

crypto/mem.c:257:9: 
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    256.           free_impl(str, file, line);
    257. >         return;
    258.       }
    259.   

crypto/mem.c:271:1: return from a call to CRYPTO_free
    269.       free(str);
    270.   #endif
    271. > }
    272.   
    273.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/x509/x509_vfy.c:2168:1: return from a call to X509_STORE_CTX_free
  2166.       X509_STORE_CTX_cleanup(ctx);
  2167.       OPENSSL_free(ctx);
  2168. > }
  2169.   
  2170.   int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509,

static int x509_certify(X509_STORE *ctx, const char *CAfile, const EVP_MD *digest,
                        X509 *x, X509 *xca, EVP_PKEY *pkey,
                        STACK_OF(OPENSSL_STRING) *sigopts,
                        const char *serialfile, int create,
                        int days, int clrext, CONF *conf, const char *section,
                        ASN1_INTEGER *sno, int reqfile)
{
    int ret = 0;
    ASN1_INTEGER *bs = NULL;
    X509_STORE_CTX *xsc = NULL;
    EVP_PKEY *upkey;
    upkey = X509_get0_pubkey(xca);
    if (upkey == NULL) {
        BIO_printf(bio_err, "Error obtaining CA X509 public key\n");
        goto end;
    }
    EVP_PKEY_copy_parameters(upkey, pkey);
    xsc = X509_STORE_CTX_new();
    if (xsc == NULL || !X509_STORE_CTX_init(xsc, ctx, x, NULL)) {
        BIO_printf(bio_err, "Error initialising X509 store\n");
        goto end;
    }
    if (sno)
        bs = sno;
    else if ((bs = x509_load_serial(CAfile, serialfile, create)) == NULL)
        goto end;
    X509_STORE_CTX_set_cert(xsc, x);
    X509_STORE_CTX_set_flags(xsc, X509_V_FLAG_CHECK_SS_SIGNATURE);
    if (!reqfile && X509_verify_cert(xsc) <= 0)
        goto end;
    if (!X509_check_private_key(xca, pkey)) {
        BIO_printf(bio_err,
                   "CA certificate and CA private key do not match\n");
        goto end;
    }
    if (!X509_set_issuer_name(x, X509_get_subject_name(xca)))
        goto end;
    if (!X509_set_serialNumber(x, bs))
        goto end;
    if (!set_cert_times(x, NULL, NULL, days))
        goto end;
    if (clrext) {
        while (X509_get_ext_count(x) > 0)
            X509_delete_ext(x, 0);
    }
    if (conf) {
        X509V3_CTX ctx2;
        X509_set_version(x, 2);
        X509V3_set_ctx(&ctx2, xca, x, NULL, NULL, 0);
        X509V3_set_nconf(&ctx2, conf);
        if (!X509V3_EXT_add_nconf(conf, &ctx2, section, x))
            goto end;
    }
    if (!do_X509_sign(x, pkey, digest, sigopts))
        goto end;
    ret = 1;
 end:
    X509_STORE_CTX_free(xsc);
    if (!ret)
        ERR_print_errors(bio_err);
    if (!sno)
        ASN1_INTEGER_free(bs);
    return ret;
}
['static int x509_certify(X509_STORE *ctx, const char *CAfile, const EVP_MD *digest,\n                        X509 *x, X509 *xca, EVP_PKEY *pkey,\n                        STACK_OF(OPENSSL_STRING) *sigopts,\n                        const char *serialfile, int create,\n                        int days, int clrext, CONF *conf, const char *section,\n                        ASN1_INTEGER *sno, int reqfile)\n{\n    int ret = 0;\n    ASN1_INTEGER *bs = NULL;\n    X509_STORE_CTX *xsc = NULL;\n    EVP_PKEY *upkey;\n    upkey = X509_get0_pubkey(xca);\n    if (upkey == NULL) {\n        BIO_printf(bio_err, "Error obtaining CA X509 public key\\n");\n        goto end;\n    }\n    EVP_PKEY_copy_parameters(upkey, pkey);\n    xsc = X509_STORE_CTX_new();\n    if (xsc == NULL || !X509_STORE_CTX_init(xsc, ctx, x, NULL)) {\n        BIO_printf(bio_err, "Error initialising X509 store\\n");\n        goto end;\n    }\n    if (sno)\n        bs = sno;\n    else if ((bs = x509_load_serial(CAfile, serialfile, create)) == NULL)\n        goto end;\n    X509_STORE_CTX_set_cert(xsc, x);\n    X509_STORE_CTX_set_flags(xsc, X509_V_FLAG_CHECK_SS_SIGNATURE);\n    if (!reqfile && X509_verify_cert(xsc) <= 0)\n        goto end;\n    if (!X509_check_private_key(xca, pkey)) {\n        BIO_printf(bio_err,\n                   "CA certificate and CA private key do not match\\n");\n        goto end;\n    }\n    if (!X509_set_issuer_name(x, X509_get_subject_name(xca)))\n        goto end;\n    if (!X509_set_serialNumber(x, bs))\n        goto end;\n    if (!set_cert_times(x, NULL, NULL, days))\n        goto end;\n    if (clrext) {\n        while (X509_get_ext_count(x) > 0)\n            X509_delete_ext(x, 0);\n    }\n    if (conf) {\n        X509V3_CTX ctx2;\n        X509_set_version(x, 2);\n        X509V3_set_ctx(&ctx2, xca, x, NULL, NULL, 0);\n        X509V3_set_nconf(&ctx2, conf);\n        if (!X509V3_EXT_add_nconf(conf, &ctx2, section, x))\n            goto end;\n    }\n    if (!do_X509_sign(x, pkey, digest, sigopts))\n        goto end;\n    ret = 1;\n end:\n    X509_STORE_CTX_free(xsc);\n    if (!ret)\n        ERR_print_errors(bio_err);\n    if (!sno)\n        ASN1_INTEGER_free(bs);\n    return ret;\n}', 'EVP_PKEY *X509_get0_pubkey(const X509 *x)\n{\n    if (x == NULL)\n        return NULL;\n    return X509_PUBKEY_get0(x->cert_info.key);\n}', 'EVP_PKEY *X509_PUBKEY_get0(X509_PUBKEY *key)\n{\n    EVP_PKEY *ret = NULL;\n    if (key == NULL || key->public_key == NULL)\n        return NULL;\n    if (key->pkey != NULL)\n        return key->pkey;\n    x509_pubkey_decode(&ret, key);\n    if (ret != NULL) {\n        X509err(X509_F_X509_PUBKEY_GET0, ERR_R_INTERNAL_ERROR);\n        EVP_PKEY_free(ret);\n    }\n    return NULL;\n}', 'int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from)\n{\n    if (to->type == EVP_PKEY_NONE) {\n        if (EVP_PKEY_set_type(to, from->type) == 0)\n            return 0;\n    } else if (to->type != from->type) {\n        EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS, EVP_R_DIFFERENT_KEY_TYPES);\n        goto err;\n    }\n    if (EVP_PKEY_missing_parameters(from)) {\n        EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS, EVP_R_MISSING_PARAMETERS);\n        goto err;\n    }\n    if (!EVP_PKEY_missing_parameters(to)) {\n        if (EVP_PKEY_cmp_parameters(to, from) == 1)\n            return 1;\n        EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS, EVP_R_DIFFERENT_PARAMETERS);\n        return 0;\n    }\n    if (from->ameth && from->ameth->param_copy)\n        return from->ameth->param_copy(to, from);\n err:\n    return 0;\n}', 'X509_STORE_CTX *X509_STORE_CTX_new(void)\n{\n    X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));\n    if (ctx == NULL) {\n        X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    return ctx;\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    FAILTEST();\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    osslargused(file); osslargused(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *x)\n{\n    ctx->cert = x;\n}', 'void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags)\n{\n    X509_VERIFY_PARAM_set_flags(ctx->param, flags);\n}', 'int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags)\n{\n    param->flags |= flags;\n    if (flags & X509_V_FLAG_POLICY_MASK)\n        param->flags |= X509_V_FLAG_POLICY_CHECK;\n    return 1;\n}', 'void X509_STORE_CTX_free(X509_STORE_CTX *ctx)\n{\n    if (ctx == NULL)\n        return;\n    X509_STORE_CTX_cleanup(ctx);\n    OPENSSL_free(ctx);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']