apps/x509.c:1240: error: NULL_DEREFERENCE
  pointer `pktmp` last assigned on line 1238 could be null and is dereferenced by call to `EVP_PKEY_save_parameters()` at line 1240, column 2.
Showing all 11 steps of the trace


apps/x509.c:1232:1: start of procedure sign()
1230.   
1231.   /* self sign */
1232. > static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext, const EVP_MD *digest, 
1233.   						CONF *conf, char *section)
1234.   	{

apps/x509.c:1238:2: 
1236.   	EVP_PKEY *pktmp;
1237.   
1238. > 	pktmp = X509_get_pubkey(x);
1239.   	EVP_PKEY_copy_parameters(pktmp,pkey);
1240.   	EVP_PKEY_save_parameters(pktmp,1);

crypto/x509/x509_cmp.c:253:1: start of procedure X509_get_pubkey()
  251.   	}
  252.   
  253. > EVP_PKEY *X509_get_pubkey(X509 *x)
  254.   	{
  255.   	if ((x == NULL) || (x->cert_info == NULL))

crypto/x509/x509_cmp.c:255:7: Taking false branch
  253.   EVP_PKEY *X509_get_pubkey(X509 *x)
  254.   	{
  255.   	if ((x == NULL) || (x->cert_info == NULL))
               ^
  256.   		return(NULL);
  257.   	return(X509_PUBKEY_get(x->cert_info->key));

crypto/x509/x509_cmp.c:255:22: Taking true branch
  253.   EVP_PKEY *X509_get_pubkey(X509 *x)
  254.   	{
  255.   	if ((x == NULL) || (x->cert_info == NULL))
                              ^
  256.   		return(NULL);
  257.   	return(X509_PUBKEY_get(x->cert_info->key));

crypto/x509/x509_cmp.c:256:3: 
  254.   	{
  255.   	if ((x == NULL) || (x->cert_info == NULL))
  256. > 		return(NULL);
  257.   	return(X509_PUBKEY_get(x->cert_info->key));
  258.   	}

crypto/x509/x509_cmp.c:258:2: return from a call to X509_get_pubkey
  256.   		return(NULL);
  257.   	return(X509_PUBKEY_get(x->cert_info->key));
  258.   	}
          ^
  259.   
  260.   ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x)

apps/x509.c:1239:2: Skipping EVP_PKEY_copy_parameters(): empty list of specs
1237.   
1238.   	pktmp = X509_get_pubkey(x);
1239.   	EVP_PKEY_copy_parameters(pktmp,pkey);
         ^
1240.   	EVP_PKEY_save_parameters(pktmp,1);
1241.   	EVP_PKEY_free(pktmp);

apps/x509.c:1240:2: 
1238.   	pktmp = X509_get_pubkey(x);
1239.   	EVP_PKEY_copy_parameters(pktmp,pkey);
1240. > 	EVP_PKEY_save_parameters(pktmp,1);
1241.   	EVP_PKEY_free(pktmp);
1242.   

crypto/evp/p_lib.c:128:1: start of procedure EVP_PKEY_save_parameters()
  126.   	}
  127.   
  128. > int EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode)
  129.   	{
  130.   #ifndef OPENSSL_NO_DSA

crypto/evp/p_lib.c:131:6: 
  129.   	{
  130.   #ifndef OPENSSL_NO_DSA
  131. > 	if (pkey->type == EVP_PKEY_DSA)
  132.   		{
  133.   		int ret=pkey->save_parameters;

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;
		X509_set_version(x,2);
                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, const EVP_MD *digest,\n\t\t\t\t\t\tCONF *conf, char *section)\n\t{\n\tEVP_PKEY *pktmp;\n\tpktmp = X509_get_pubkey(x);\n\tEVP_PKEY_copy_parameters(pktmp,pkey);\n\tEVP_PKEY_save_parameters(pktmp,1);\n\tEVP_PKEY_free(pktmp);\n\tif (!X509_set_issuer_name(x,X509_get_subject_name(x))) goto err;\n\tif (X509_gmtime_adj(X509_get_notBefore(x),0) == NULL) goto err;\n\tif (X509_gmtime_adj(X509_get_notAfter(x),(long)60*60*24*days) == NULL)\n\t\tgoto err;\n\tif (!X509_set_pubkey(x,pkey)) goto err;\n\tif (clrext)\n\t\t{\n\t\twhile (X509_get_ext_count(x) > 0) X509_delete_ext(x, 0);\n\t\t}\n\tif (conf)\n\t\t{\n\t\tX509V3_CTX ctx;\n\t\tX509_set_version(x,2);\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)) goto err;\n\t\t}\n\tif (!X509_sign(x,pkey,digest)) goto err;\n\treturn 1;\nerr:\n\tERR_print_errors(bio_err);\n\treturn 0;\n\t}', 'EVP_PKEY *X509_get_pubkey(X509 *x)\n\t{\n\tif ((x == NULL) || (x->cert_info == NULL))\n\t\treturn(NULL);\n\treturn(X509_PUBKEY_get(x->cert_info->key));\n\t}', 'int EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode)\n\t{\n#ifndef OPENSSL_NO_DSA\n\tif (pkey->type == EVP_PKEY_DSA)\n\t\t{\n\t\tint ret=pkey->save_parameters;\n\t\tif (mode >= 0)\n\t\t\tpkey->save_parameters=mode;\n\t\treturn(ret);\n\t\t}\n#endif\n#ifndef OPENSSL_NO_ECDSA\n\tif (pkey->type == EVP_PKEY_ECDSA)\n\t\t{\n\t\tint ret = pkey->save_parameters;\n\t\tif (mode >= 0)\n\t\t\tpkey->save_parameters = mode;\n\t\treturn(ret);\n\t\t}\n#endif\n\treturn(0);\n\t}']