ssl/ssl_rsa.c:220: error: NULL_DEREFERENCE
  pointer `pktmp` last assigned on line 219 could be null and is dereferenced by call to `EVP_PKEY_copy_parameters()` at line 220, column 3.
Showing all 12 steps of the trace


ssl/ssl_rsa.c:190:1: start of procedure ssl_set_pkey()
188.   #endif
189.   
190. > static int ssl_set_pkey(CERT *c, EVP_PKEY *pkey)
191.   	{
192.   	int i;

ssl/ssl_rsa.c:196:6: Taking false branch
194.   	 * This means for DH certificates we must set the certificate first.
195.   	 */
196.   	if (pkey->type == EVP_PKEY_DH)
            ^
197.   		{
198.   		X509 *x;

ssl/ssl_rsa.c:209:3: Skipping ssl_cert_type(): empty list of specs
207.   		}
208.   	else 
209.   		i=ssl_cert_type(NULL,pkey);
         ^
210.   	if (i < 0)
211.   		{

ssl/ssl_rsa.c:210:6: Taking false branch
208.   	else 
209.   		i=ssl_cert_type(NULL,pkey);
210.   	if (i < 0)
            ^
211.   		{
212.   		SSLerr(SSL_F_SSL_SET_PKEY,SSL_R_UNKNOWN_CERTIFICATE_TYPE);

ssl/ssl_rsa.c:216:6: Taking true branch
214.   		}
215.   
216.   	if (c->pkeys[i].x509 != NULL)
            ^
217.   		{
218.   		EVP_PKEY *pktmp;

ssl/ssl_rsa.c:219:3: 
217.   		{
218.   		EVP_PKEY *pktmp;
219. > 		pktmp =	X509_get_pubkey(c->pkeys[i].x509);
220.   		EVP_PKEY_copy_parameters(pktmp,pkey);
221.   		EVP_PKEY_free(pktmp);

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

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

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

crypto/x509/x509_cmp.c:316:3: 
  314.   	{
  315.   	if ((x == NULL) || (x->cert_info == NULL))
  316. > 		return(NULL);
  317.   	return(X509_PUBKEY_get(x->cert_info->key));
  318.   	}

crypto/x509/x509_cmp.c:318:2: return from a call to X509_get_pubkey
  316.   		return(NULL);
  317.   	return(X509_PUBKEY_get(x->cert_info->key));
  318.   	}
          ^
  319.   
  320.   ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x)

ssl/ssl_rsa.c:220:3: 
218.   		EVP_PKEY *pktmp;
219.   		pktmp =	X509_get_pubkey(c->pkeys[i].x509);
220. > 		EVP_PKEY_copy_parameters(pktmp,pkey);
221.   		EVP_PKEY_free(pktmp);
222.   		ERR_clear_error();

static int ssl_set_pkey(CERT *c, EVP_PKEY *pkey)
	{
	int i;
	if (pkey->type == EVP_PKEY_DH)
		{
		X509 *x;
		i = -1;
		x = c->pkeys[SSL_PKEY_DH_RSA].x509;
		if (x && X509_check_private_key(x, pkey))
				i = SSL_PKEY_DH_RSA;
		x = c->pkeys[SSL_PKEY_DH_DSA].x509;
		if (i == -1 && x && X509_check_private_key(x, pkey))
				i = SSL_PKEY_DH_DSA;
		ERR_clear_error();
		}
	else
		i=ssl_cert_type(NULL,pkey);
	if (i < 0)
		{
		SSLerr(SSL_F_SSL_SET_PKEY,SSL_R_UNKNOWN_CERTIFICATE_TYPE);
		return(0);
		}
	if (c->pkeys[i].x509 != NULL)
		{
		EVP_PKEY *pktmp;
		pktmp =	X509_get_pubkey(c->pkeys[i].x509);
		EVP_PKEY_copy_parameters(pktmp,pkey);
		EVP_PKEY_free(pktmp);
		ERR_clear_error();
#ifndef OPENSSL_NO_RSA
		if ((pkey->type == EVP_PKEY_RSA) &&
			(RSA_flags(pkey->pkey.rsa) & RSA_METHOD_FLAG_NO_CHECK))
			;
		else
#endif
		if (!X509_check_private_key(c->pkeys[i].x509,pkey))
			{
			X509_free(c->pkeys[i].x509);
			c->pkeys[i].x509 = NULL;
			return 0;
			}
		}
	if (c->pkeys[i].privatekey != NULL)
		EVP_PKEY_free(c->pkeys[i].privatekey);
	CRYPTO_add(&pkey->references,1,CRYPTO_LOCK_EVP_PKEY);
	c->pkeys[i].privatekey=pkey;
	c->key= &(c->pkeys[i]);
	c->valid=0;
	return(1);
	}
['static int ssl_set_pkey(CERT *c, EVP_PKEY *pkey)\n\t{\n\tint i;\n\tif (pkey->type == EVP_PKEY_DH)\n\t\t{\n\t\tX509 *x;\n\t\ti = -1;\n\t\tx = c->pkeys[SSL_PKEY_DH_RSA].x509;\n\t\tif (x && X509_check_private_key(x, pkey))\n\t\t\t\ti = SSL_PKEY_DH_RSA;\n\t\tx = c->pkeys[SSL_PKEY_DH_DSA].x509;\n\t\tif (i == -1 && x && X509_check_private_key(x, pkey))\n\t\t\t\ti = SSL_PKEY_DH_DSA;\n\t\tERR_clear_error();\n\t\t}\n\telse\n\t\ti=ssl_cert_type(NULL,pkey);\n\tif (i < 0)\n\t\t{\n\t\tSSLerr(SSL_F_SSL_SET_PKEY,SSL_R_UNKNOWN_CERTIFICATE_TYPE);\n\t\treturn(0);\n\t\t}\n\tif (c->pkeys[i].x509 != NULL)\n\t\t{\n\t\tEVP_PKEY *pktmp;\n\t\tpktmp =\tX509_get_pubkey(c->pkeys[i].x509);\n\t\tEVP_PKEY_copy_parameters(pktmp,pkey);\n\t\tEVP_PKEY_free(pktmp);\n\t\tERR_clear_error();\n#ifndef OPENSSL_NO_RSA\n\t\tif ((pkey->type == EVP_PKEY_RSA) &&\n\t\t\t(RSA_flags(pkey->pkey.rsa) & RSA_METHOD_FLAG_NO_CHECK))\n\t\t\t;\n\t\telse\n#endif\n\t\tif (!X509_check_private_key(c->pkeys[i].x509,pkey))\n\t\t\t{\n\t\t\tX509_free(c->pkeys[i].x509);\n\t\t\tc->pkeys[i].x509 = NULL;\n\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\tif (c->pkeys[i].privatekey != NULL)\n\t\tEVP_PKEY_free(c->pkeys[i].privatekey);\n\tCRYPTO_add(&pkey->references,1,CRYPTO_LOCK_EVP_PKEY);\n\tc->pkeys[i].privatekey=pkey;\n\tc->key= &(c->pkeys[i]);\n\tc->valid=0;\n\treturn(1);\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}']