crypto/x509/x509_vfy.c:776: error: NULL_DEREFERENCE
  pointer `x` last assigned on line 775 could be null and is dereferenced by call to `lookup_cert_match()` at line 776, column 14.
Showing all 31 steps of the trace


crypto/x509/x509_vfy.c:722:1: start of procedure check_trust()
720.   }
721.   
722. > static int check_trust(X509_STORE_CTX *ctx, int num_untrusted)
723.   {
724.       int i;

crypto/x509/x509_vfy.c:725:5: 
723.   {
724.       int i;
725. >     X509 *x = NULL;
726.       X509 *mx;
727.       SSL_DANE *dane = ctx->dane;

crypto/x509/x509_vfy.c:727:5: 
725.       X509 *x = NULL;
726.       X509 *mx;
727. >     SSL_DANE *dane = ctx->dane;
728.       int num = sk_X509_num(ctx->chain);
729.       int trust;

crypto/x509/x509_vfy.c:728:5: 
726.       X509 *mx;
727.       SSL_DANE *dane = ctx->dane;
728. >     int num = sk_X509_num(ctx->chain);
729.       int trust;
730.   

include/openssl/x509.h:99:1: start of procedure sk_X509_num()
  97.   typedef struct x509_cinf_st X509_CINF;
  98.   
  99. > DEFINE_STACK_OF(X509)
  100.   
  101.   /* This is used for a table of trust checking functions */

crypto/stack/stack.c:376:1: start of procedure OPENSSL_sk_num()
    374.   }
    375.   
    376. > int OPENSSL_sk_num(const OPENSSL_STACK *st)
    377.   {
    378.       return st == NULL ? -1 : st->num;

crypto/stack/stack.c:378:12: Condition is true
    376.   int OPENSSL_sk_num(const OPENSSL_STACK *st)
    377.   {
    378.       return st == NULL ? -1 : st->num;
                      ^
    379.   }
    380.   

crypto/stack/stack.c:378:5: 
    376.   int OPENSSL_sk_num(const OPENSSL_STACK *st)
    377.   {
    378. >     return st == NULL ? -1 : st->num;
    379.   }
    380.   

crypto/stack/stack.c:379:1: return from a call to OPENSSL_sk_num
    377.   {
    378.       return st == NULL ? -1 : st->num;
    379. > }
    380.   
    381.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)

include/openssl/x509.h:99:1: return from a call to sk_X509_num
  97.   typedef struct x509_cinf_st X509_CINF;
  98.   
  99. > DEFINE_STACK_OF(X509)
  100.   
  101.   /* This is used for a table of trust checking functions */

crypto/x509/x509_vfy.c:735:9: Taking true branch
733.        * match, we're done, otherwise we'll merely record the match depth.
734.        */
735.       if (DANETLS_HAS_TA(dane) && num_untrusted > 0 && num_untrusted < num) {
               ^
736.           switch (trust = check_dane_issuer(ctx, num_untrusted)) {
737.           case X509_TRUST_TRUSTED:

crypto/x509/x509_vfy.c:735:9: Taking false branch
733.        * match, we're done, otherwise we'll merely record the match depth.
734.        */
735.       if (DANETLS_HAS_TA(dane) && num_untrusted > 0 && num_untrusted < num) {
               ^
736.           switch (trust = check_dane_issuer(ctx, num_untrusted)) {
737.           case X509_TRUST_TRUSTED:

crypto/x509/x509_vfy.c:749:10: 
747.        * and wants to incrementally check just any added since.
748.        */
749. >     for (i = num_untrusted; i < num; i++) {
750.           x = sk_X509_value(ctx->chain, i);
751.           trust = X509_check_trust(x, ctx->param->trust, 0);

crypto/x509/x509_vfy.c:749:29: Loop condition is false. Leaving loop
747.        * and wants to incrementally check just any added since.
748.        */
749.       for (i = num_untrusted; i < num; i++) {
                                   ^
750.           x = sk_X509_value(ctx->chain, i);
751.           trust = X509_check_trust(x, ctx->param->trust, 0);

crypto/x509/x509_vfy.c:763:9: Taking false branch
761.        * the chain is PKIX trusted.
762.        */
763.       if (num_untrusted < num) {
               ^
764.           if (ctx->param->flags & X509_V_FLAG_PARTIAL_CHAIN)
765.               goto trusted;

crypto/x509/x509_vfy.c:769:9: Taking true branch
767.       }
768.   
769.       if (num_untrusted == num && ctx->param->flags & X509_V_FLAG_PARTIAL_CHAIN) {
               ^
770.           /*
771.            * Last-resort call with no new trusted certificates, check the leaf

crypto/x509/x509_vfy.c:769:33: Taking true branch
767.       }
768.   
769.       if (num_untrusted == num && ctx->param->flags & X509_V_FLAG_PARTIAL_CHAIN) {
                                       ^
770.           /*
771.            * Last-resort call with no new trusted certificates, check the leaf

crypto/x509/x509_vfy.c:774:9: 
772.            * for a direct trust store match.
773.            */
774. >         i = 0;
775.           x = sk_X509_value(ctx->chain, i);
776.           mx = lookup_cert_match(ctx, x);

crypto/x509/x509_vfy.c:775:9: 
773.            */
774.           i = 0;
775. >         x = sk_X509_value(ctx->chain, i);
776.           mx = lookup_cert_match(ctx, x);
777.           if (!mx)

include/openssl/x509.h:99:1: start of procedure sk_X509_value()
  97.   typedef struct x509_cinf_st X509_CINF;
  98.   
  99. > DEFINE_STACK_OF(X509)
  100.   
  101.   /* This is used for a table of trust checking functions */

crypto/stack/stack.c:381:1: start of procedure OPENSSL_sk_value()
    379.   }
    380.   
    381. > void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    382.   {
    383.       if (st == NULL || i < 0 || i >= st->num)

crypto/stack/stack.c:383:9: Taking true branch
    381.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    382.   {
    383.       if (st == NULL || i < 0 || i >= st->num)
                   ^
    384.           return NULL;
    385.       return (void *)st->data[i];

crypto/stack/stack.c:384:9: 
    382.   {
    383.       if (st == NULL || i < 0 || i >= st->num)
    384. >         return NULL;
    385.       return (void *)st->data[i];
    386.   }

crypto/stack/stack.c:386:1: return from a call to OPENSSL_sk_value
    384.           return NULL;
    385.       return (void *)st->data[i];
    386. > }
    387.   
    388.   void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data)

include/openssl/x509.h:99:1: return from a call to sk_X509_value
  97.   typedef struct x509_cinf_st X509_CINF;
  98.   
  99. > DEFINE_STACK_OF(X509)
  100.   
  101.   /* This is used for a table of trust checking functions */

crypto/x509/x509_vfy.c:776:9: 
774.           i = 0;
775.           x = sk_X509_value(ctx->chain, i);
776. >         mx = lookup_cert_match(ctx, x);
777.           if (!mx)
778.               return X509_TRUST_UNTRUSTED;

crypto/x509/x509_vfy.c:124:1: start of procedure lookup_cert_match()
  122.   /* Given a certificate try and find an exact match in the store */
  123.   
  124. > static X509 *lookup_cert_match(X509_STORE_CTX *ctx, X509 *x)
  125.   {
  126.       STACK_OF(X509) *certs;

crypto/x509/x509_vfy.c:127:5: 
  125.   {
  126.       STACK_OF(X509) *certs;
  127. >     X509 *xtmp = NULL;
  128.       int i;
  129.       /* Lookup all certs with matching subject name */

crypto/x509/x509_vfy.c:130:5: 
  128.       int i;
  129.       /* Lookup all certs with matching subject name */
  130. >     certs = ctx->lookup_certs(ctx, X509_get_subject_name(x));
  131.       if (certs == NULL)
  132.           return NULL;

crypto/x509/x509_cmp.c:99:1: start of procedure X509_get_subject_name()
    97.   #endif
    98.   
    99. > X509_NAME *X509_get_subject_name(const X509 *a)
    100.   {
    101.       return a->cert_info.subject;

crypto/x509/x509_cmp.c:101:5: 
    99.   X509_NAME *X509_get_subject_name(const X509 *a)
    100.   {
    101. >     return a->cert_info.subject;
    102.   }
    103.   
