ssl/s3_srvr.c:2821: error: NULL_DEREFERENCE
  pointer `pkey` last assigned on line 2800 could be null and is dereferenced at line 2821, column 20.
Showing all 30 steps of the trace


ssl/s3_srvr.c:2763:1: start of procedure ssl3_get_cert_verify()
2761.   }
2762.   
2763. > int ssl3_get_cert_verify(SSL *s)
2764.   {
2765.       EVP_PKEY *pkey = NULL;

ssl/s3_srvr.c:2765:5: 
2763.   int ssl3_get_cert_verify(SSL *s)
2764.   {
2765. >     EVP_PKEY *pkey = NULL;
2766.       unsigned char *sig, *data;
2767.       int al, ok, ret = 0;

ssl/s3_srvr.c:2767:5: 
2765.       EVP_PKEY *pkey = NULL;
2766.       unsigned char *sig, *data;
2767. >     int al, ok, ret = 0;
2768.       long n;
2769.       int type = 0, i, j;

ssl/s3_srvr.c:2769:5: 
2767.       int al, ok, ret = 0;
2768.       long n;
2769. >     int type = 0, i, j;
2770.       unsigned int len;
2771.       X509 *peer;

ssl/s3_srvr.c:2772:5: 
2770.       unsigned int len;
2771.       X509 *peer;
2772. >     const EVP_MD *md = NULL;
2773.       EVP_MD_CTX mctx;
2774.       PACKET pkt;

ssl/s3_srvr.c:2775:5: 
2773.       EVP_MD_CTX mctx;
2774.       PACKET pkt;
2775. >     EVP_MD_CTX_init(&mctx);
2776.   
2777.       /*

crypto/evp/digest.c:120:1: start of procedure EVP_MD_CTX_init()
  118.   #endif
  119.   
  120. > void EVP_MD_CTX_init(EVP_MD_CTX *ctx)
  121.   {
  122.       memset(ctx, 0, sizeof(*ctx));

crypto/evp/digest.c:122:5: 
  120.   void EVP_MD_CTX_init(EVP_MD_CTX *ctx)
  121.   {
  122. >     memset(ctx, 0, sizeof(*ctx));
  123.   }
  124.   

crypto/evp/digest.c:123:1: return from a call to EVP_MD_CTX_init
  121.   {
  122.       memset(ctx, 0, sizeof(*ctx));
  123. > }
  124.   
  125.   EVP_MD_CTX *EVP_MD_CTX_create(void)

ssl/s3_srvr.c:2785:9: Taking false branch
2783.        * CertificateVerify state so we should not arrive here.
2784.        */
2785.       if (s->session->peer == NULL) {
                ^
2786.           ret = 1;
2787.           goto end;

ssl/s3_srvr.c:2790:5: Skipping __function_pointer__(): unresolved function pointer
2788.       }
2789.   
2790.       n = s->method->ssl_get_message(s,
            ^
2791.                                      SSL3_ST_SR_CERT_VRFY_A,
2792.                                      SSL3_ST_SR_CERT_VRFY_B,

ssl/s3_srvr.c:2796:10: Taking false branch
2794.                                      SSL3_RT_MAX_PLAIN_LENGTH, &ok);
2795.   
2796.       if (!ok)
                 ^
2797.           return ((int)n);
2798.   

ssl/s3_srvr.c:2799:5: 
2797.           return ((int)n);
2798.   
2799. >     peer = s->session->peer;
2800.       pkey = X509_get_pubkey(peer);
2801.       type = X509_certificate_type(peer, pkey);

ssl/s3_srvr.c:2800:5: 
2798.   
2799.       peer = s->session->peer;
2800. >     pkey = X509_get_pubkey(peer);
2801.       type = X509_certificate_type(peer, pkey);
2802.   

crypto/x509/x509_cmp.c:305:1: start of procedure X509_get_pubkey()
  303.   }
  304.   
  305. > EVP_PKEY *X509_get_pubkey(X509 *x)
  306.   {
  307.       if (x == NULL)

crypto/x509/x509_cmp.c:307:9: Taking true branch
  305.   EVP_PKEY *X509_get_pubkey(X509 *x)
  306.   {
  307.       if (x == NULL)
                 ^
  308.           return (NULL);
  309.       return (X509_PUBKEY_get(x->cert_info.key));

crypto/x509/x509_cmp.c:308:9: 
  306.   {
  307.       if (x == NULL)
  308. >         return (NULL);
  309.       return (X509_PUBKEY_get(x->cert_info.key));
  310.   }

crypto/x509/x509_cmp.c:310:1: return from a call to X509_get_pubkey
  308.           return (NULL);
  309.       return (X509_PUBKEY_get(x->cert_info.key));
  310. > }
  311.   
  312.   ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x)

ssl/s3_srvr.c:2801:5: Skipping X509_certificate_type(): empty list of specs
2799.       peer = s->session->peer;
2800.       pkey = X509_get_pubkey(peer);
2801.       type = X509_certificate_type(peer, pkey);
            ^
2802.   
2803.       if (!(type & EVP_PKT_SIGN)) {

ssl/s3_srvr.c:2803:11: Taking false branch
2801.       type = X509_certificate_type(peer, pkey);
2802.   
2803.       if (!(type & EVP_PKT_SIGN)) {
                  ^
2804.           SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,
2805.                  SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE);

ssl/s3_srvr.c:2811:10: 
2809.   
2810.       /* we now have a signature that we need to verify */
2811. >     if (!PACKET_buf_init(&pkt, s->init_msg, n)) {
2812.           SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, ERR_R_INTERNAL_ERROR);
2813.           al = SSL_AD_INTERNAL_ERROR;

ssl/packet_locl.h:110:1: start of procedure PACKET_buf_init()
  108.    * is being used.
  109.    */
  110. > static inline int PACKET_buf_init(PACKET *pkt, unsigned char *buf, size_t len)
  111.   {
  112.       /* Sanity check for negative values. */

ssl/packet_locl.h:113:9: Taking false branch
  111.   {
  112.       /* Sanity check for negative values. */
  113.       if (buf + len < buf)
                 ^
  114.           return 0;
  115.   

ssl/packet_locl.h:116:5: 
  114.           return 0;
  115.   
  116. >     pkt->curr = buf;
  117.       pkt->remaining = len;
  118.       return 1;

ssl/packet_locl.h:117:5: 
  115.   
  116.       pkt->curr = buf;
  117. >     pkt->remaining = len;
  118.       return 1;
  119.   }

ssl/packet_locl.h:118:5: 
  116.       pkt->curr = buf;
  117.       pkt->remaining = len;
  118. >     return 1;
  119.   }
  120.   

ssl/packet_locl.h:119:1: return from a call to PACKET_buf_init
  117.       pkt->remaining = len;
  118.       return 1;
  119. > }
  120.   
  121.   /* Initialize a PACKET to hold zero bytes. */

ssl/s3_srvr.c:2811:10: Taking false branch
2809.   
2810.       /* we now have a signature that we need to verify */
2811.       if (!PACKET_buf_init(&pkt, s->init_msg, n)) {
                 ^
2812.           SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, ERR_R_INTERNAL_ERROR);
2813.           al = SSL_AD_INTERNAL_ERROR;

ssl/s3_srvr.c:2821:9: Taking true branch
2819.        * length field
2820.        */
2821.       if (n == 64 && pkey->type == NID_id_GostR3410_2001) {
                ^
2822.           len = 64;
2823.       } else {

ssl/s3_srvr.c:2821:20: 
2819.        * length field
2820.        */
2821. >     if (n == 64 && pkey->type == NID_id_GostR3410_2001) {
2822.           len = 64;
2823.       } else {
