apps/x509.c:1212: error: NULL_DEREFERENCE
  pointer `pktmp` last assigned on line 1211 could be null and is dereferenced by call to `EVP_PKEY_copy_parameters()` at line 1212, column 5.
Showing all 8 steps of the trace


apps/x509.c:1205:1: start of procedure sign()
1203.   
1204.   /* self sign */
1205. > static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext,
1206.                   const EVP_MD *digest, CONF *conf, char *section)
1207.   {

apps/x509.c:1211:5: 
1209.       EVP_PKEY *pktmp;
1210.   
1211. >     pktmp = X509_get_pubkey(x);
1212.       EVP_PKEY_copy_parameters(pktmp, pkey);
1213.       EVP_PKEY_save_parameters(pktmp, 1);

crypto/x509/x509_cmp.c:310:1: start of procedure X509_get_pubkey()
  308.   }
  309.   
  310. > EVP_PKEY *X509_get_pubkey(X509 *x)
  311.   {
  312.       if ((x == NULL) || (x->cert_info == NULL))

crypto/x509/x509_cmp.c:312:10: Taking false branch
  310.   EVP_PKEY *X509_get_pubkey(X509 *x)
  311.   {
  312.       if ((x == NULL) || (x->cert_info == NULL))
                  ^
  313.           return (NULL);
  314.       return (X509_PUBKEY_get(x->cert_info->key));

crypto/x509/x509_cmp.c:312:25: Taking true branch
  310.   EVP_PKEY *X509_get_pubkey(X509 *x)
  311.   {
  312.       if ((x == NULL) || (x->cert_info == NULL))
                                 ^
  313.           return (NULL);
  314.       return (X509_PUBKEY_get(x->cert_info->key));

crypto/x509/x509_cmp.c:313:9: 
  311.   {
  312.       if ((x == NULL) || (x->cert_info == NULL))
  313. >         return (NULL);
  314.       return (X509_PUBKEY_get(x->cert_info->key));
  315.   }

crypto/x509/x509_cmp.c:315:1: return from a call to X509_get_pubkey
  313.           return (NULL);
  314.       return (X509_PUBKEY_get(x->cert_info->key));
  315. > }
  316.   
  317.   ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x)

apps/x509.c:1212:5: 
1210.   
1211.       pktmp = X509_get_pubkey(x);
1212. >     EVP_PKEY_copy_parameters(pktmp, pkey);
1213.       EVP_PKEY_save_parameters(pktmp, 1);
1214.       EVP_PKEY_free(pktmp);

static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext,
                const EVP_MD *digest, CONF *conf, char *section)
{
    EVP_PKEY *pktmp;
    pktmp = X509_get_pubkey(x);
    EVP_PKEY_copy_parameters(pktmp, pkey);
    EVP_PKEY_save_parameters(pktmp, 1);
    EVP_PKEY_free(pktmp);
    if (!X509_set_issuer_name(x, X509_get_subject_name(x)))
        goto err;
    if (X509_gmtime_adj(X509_get_notBefore(x), 0) == NULL)
        goto err;
    if (X509_gmtime_adj(X509_get_notAfter(x), (long)60 * 60 * 24 * days) ==
        NULL)
        goto err;
    if (!X509_set_pubkey(x, pkey))
        goto err;
    if (clrext) {
        while (X509_get_ext_count(x) > 0)
            X509_delete_ext(x, 0);
    }
    if (conf) {
        X509V3_CTX ctx;
#ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
        X509_set_version(x, force_version);
#else
        X509_set_version(x, 2);
#endif
        X509V3_set_ctx(&ctx, x, x, NULL, NULL, 0);
        X509V3_set_nconf(&ctx, conf);
        if (!X509V3_EXT_add_nconf(conf, &ctx, section, x))
            goto err;
    }
    if (!X509_sign(x, pkey, digest))
        goto err;
    return 1;
 err:
    ERR_print_errors(bio_err);
    return 0;
}
['static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext,\n                const EVP_MD *digest, CONF *conf, char *section)\n{\n    EVP_PKEY *pktmp;\n    pktmp = X509_get_pubkey(x);\n    EVP_PKEY_copy_parameters(pktmp, pkey);\n    EVP_PKEY_save_parameters(pktmp, 1);\n    EVP_PKEY_free(pktmp);\n    if (!X509_set_issuer_name(x, X509_get_subject_name(x)))\n        goto err;\n    if (X509_gmtime_adj(X509_get_notBefore(x), 0) == NULL)\n        goto err;\n    if (X509_gmtime_adj(X509_get_notAfter(x), (long)60 * 60 * 24 * days) ==\n        NULL)\n        goto err;\n    if (!X509_set_pubkey(x, pkey))\n        goto err;\n    if (clrext) {\n        while (X509_get_ext_count(x) > 0)\n            X509_delete_ext(x, 0);\n    }\n    if (conf) {\n        X509V3_CTX ctx;\n#ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL\n        X509_set_version(x, force_version);\n#else\n        X509_set_version(x, 2);\n#endif\n        X509V3_set_ctx(&ctx, x, x, NULL, NULL, 0);\n        X509V3_set_nconf(&ctx, conf);\n        if (!X509V3_EXT_add_nconf(conf, &ctx, section, x))\n            goto err;\n    }\n    if (!X509_sign(x, pkey, digest))\n        goto err;\n    return 1;\n err:\n    ERR_print_errors(bio_err);\n    return 0;\n}', 'EVP_PKEY *X509_get_pubkey(X509 *x)\n{\n    if ((x == NULL) || (x->cert_info == NULL))\n        return (NULL);\n    return (X509_PUBKEY_get(x->cert_info->key));\n}']