crypto/x509/x509_lu.c:470: error: NULL_DEREFERENCE
  pointer `&tobj` last assigned on line 469 could be null and is dereferenced by call to `x509_object_cmp()` at line 470, column 17.
Showing all 47 steps of the trace


crypto/x509/x509_lu.c:439:1: start of procedure x509_object_idx_cnt()
437.   }
438.   
439. > static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type,
440.                                  X509_NAME *name, int *pnmatch)
441.   {

crypto/x509/x509_lu.c:447:5: 
445.       int idx;
446.   
447. >     stmp.type = type;
448.       switch (type) {
449.       case X509_LU_X509:

crypto/x509/x509_lu.c:448:5: 
446.   
447.       stmp.type = type;
448. >     switch (type) {
449.       case X509_LU_X509:
450.           stmp.data.x509 = &x509_s;

crypto/x509/x509_lu.c:449:5: Switch condition is true. Entering switch case
447.       stmp.type = type;
448.       switch (type) {
449.       case X509_LU_X509:
           ^
450.           stmp.data.x509 = &x509_s;
451.           x509_s.cert_info.subject = name;

crypto/x509/x509_lu.c:450:9: 
448.       switch (type) {
449.       case X509_LU_X509:
450. >         stmp.data.x509 = &x509_s;
451.           x509_s.cert_info.subject = name;
452.           break;

crypto/x509/x509_lu.c:451:9: 
449.       case X509_LU_X509:
450.           stmp.data.x509 = &x509_s;
451. >         x509_s.cert_info.subject = name;
452.           break;
453.       case X509_LU_CRL:

crypto/x509/x509_lu.c:462:5: 
460.       }
461.   
462. >     idx = sk_X509_OBJECT_find(h, &stmp);
463.       if (idx >= 0 && pnmatch) {
464.           int tidx;

include/openssl/x509_vfy.h:58:1: start of procedure sk_X509_OBJECT_find()
  56.   
  57.   DEFINE_STACK_OF(X509_LOOKUP)
  58. > DEFINE_STACK_OF(X509_OBJECT)
  59.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  60.   

crypto/stack/stack.c:197:1: start of procedure OPENSSL_sk_find()
    195.   }
    196.   
    197. > int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)
    198.   {
    199.       return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);

crypto/stack/stack.c:199:5: 
    197.   int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)
    198.   {
    199. >     return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);
    200.   }
    201.   

crypto/stack/stack.c:172:1: start of procedure internal_find()
      170.   }
      171.   
      172. > static int internal_find(OPENSSL_STACK *st, const void *data,
      173.                            int ret_val_options)
      174.   {

crypto/stack/stack.c:178:9: Taking false branch
      176.       int i;
      177.   
      178.       if (st == NULL)
                     ^
      179.           return -1;
      180.   

crypto/stack/stack.c:181:9: Taking true branch
      179.           return -1;
      180.   
      181.       if (st->comp == NULL) {
                     ^
      182.           for (i = 0; i < st->num; i++)
      183.               if (st->data[i] == data)

crypto/stack/stack.c:182:14: 
      180.   
      181.       if (st->comp == NULL) {
      182. >         for (i = 0; i < st->num; i++)
      183.               if (st->data[i] == data)
      184.                   return (i);

crypto/stack/stack.c:182:21: Loop condition is true. Entering loop body
      180.   
      181.       if (st->comp == NULL) {
      182.           for (i = 0; i < st->num; i++)
                                 ^
      183.               if (st->data[i] == data)
      184.                   return (i);

crypto/stack/stack.c:183:17: Taking false branch
      181.       if (st->comp == NULL) {
      182.           for (i = 0; i < st->num; i++)
      183.               if (st->data[i] == data)
                             ^
      184.                   return (i);
      185.           return (-1);

crypto/stack/stack.c:182:34: 
      180.   
      181.       if (st->comp == NULL) {
      182. >         for (i = 0; i < st->num; i++)
      183.               if (st->data[i] == data)
      184.                   return (i);

crypto/stack/stack.c:182:21: Loop condition is true. Entering loop body
      180.   
      181.       if (st->comp == NULL) {
      182.           for (i = 0; i < st->num; i++)
                                 ^
      183.               if (st->data[i] == data)
      184.                   return (i);

crypto/stack/stack.c:183:17: Taking true branch
      181.       if (st->comp == NULL) {
      182.           for (i = 0; i < st->num; i++)
      183.               if (st->data[i] == data)
                             ^
      184.                   return (i);
      185.           return (-1);

crypto/stack/stack.c:184:17: 
      182.           for (i = 0; i < st->num; i++)
      183.               if (st->data[i] == data)
      184. >                 return (i);
      185.           return (-1);
      186.       }

crypto/stack/stack.c:195:1: return from a call to internal_find
      193.           return (-1);
      194.       return (int)((char **)r - st->data);
      195. > }
      196.   
      197.   int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)

crypto/stack/stack.c:200:1: return from a call to OPENSSL_sk_find
    198.   {
    199.       return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);
    200. > }
    201.   
    202.   int OPENSSL_sk_find_ex(OPENSSL_STACK *st, const void *data)

include/openssl/x509_vfy.h:58:1: return from a call to sk_X509_OBJECT_find
  56.   
  57.   DEFINE_STACK_OF(X509_LOOKUP)
  58. > DEFINE_STACK_OF(X509_OBJECT)
  59.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  60.   

crypto/x509/x509_lu.c:463:9: Taking true branch
461.   
462.       idx = sk_X509_OBJECT_find(h, &stmp);
463.       if (idx >= 0 && pnmatch) {
               ^
464.           int tidx;
465.           const X509_OBJECT *tobj, *pstmp;

crypto/x509/x509_lu.c:463:21: Taking true branch
461.   
462.       idx = sk_X509_OBJECT_find(h, &stmp);
463.       if (idx >= 0 && pnmatch) {
                           ^
464.           int tidx;
465.           const X509_OBJECT *tobj, *pstmp;

crypto/x509/x509_lu.c:466:9: 
464.           int tidx;
465.           const X509_OBJECT *tobj, *pstmp;
466. >         *pnmatch = 1;
467.           pstmp = &stmp;
468.           for (tidx = idx + 1; tidx < sk_X509_OBJECT_num(h); tidx++) {

crypto/x509/x509_lu.c:467:9: 
465.           const X509_OBJECT *tobj, *pstmp;
466.           *pnmatch = 1;
467. >         pstmp = &stmp;
468.           for (tidx = idx + 1; tidx < sk_X509_OBJECT_num(h); tidx++) {
469.               tobj = sk_X509_OBJECT_value(h, tidx);

crypto/x509/x509_lu.c:468:14: 
466.           *pnmatch = 1;
467.           pstmp = &stmp;
468. >         for (tidx = idx + 1; tidx < sk_X509_OBJECT_num(h); tidx++) {
469.               tobj = sk_X509_OBJECT_value(h, tidx);
470.               if (x509_object_cmp(&tobj, &pstmp))

crypto/x509/x509_lu.c:468:30: 
466.           *pnmatch = 1;
467.           pstmp = &stmp;
468. >         for (tidx = idx + 1; tidx < sk_X509_OBJECT_num(h); tidx++) {
469.               tobj = sk_X509_OBJECT_value(h, tidx);
470.               if (x509_object_cmp(&tobj, &pstmp))

include/openssl/x509_vfy.h:58:1: start of procedure sk_X509_OBJECT_num()
  56.   
  57.   DEFINE_STACK_OF(X509_LOOKUP)
  58. > DEFINE_STACK_OF(X509_OBJECT)
  59.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  60.   

crypto/stack/stack.c:265:1: start of procedure OPENSSL_sk_num()
    263.   }
    264.   
    265. > int OPENSSL_sk_num(const OPENSSL_STACK *st)
    266.   {
    267.       if (st == NULL)

crypto/stack/stack.c:267:9: Taking false branch
    265.   int OPENSSL_sk_num(const OPENSSL_STACK *st)
    266.   {
    267.       if (st == NULL)
                   ^
    268.           return -1;
    269.       return st->num;

crypto/stack/stack.c:269:5: 
    267.       if (st == NULL)
    268.           return -1;
    269. >     return st->num;
    270.   }
    271.   

crypto/stack/stack.c:270:1: return from a call to OPENSSL_sk_num
    268.           return -1;
    269.       return st->num;
    270. > }
    271.   
    272.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)

include/openssl/x509_vfy.h:58:1: return from a call to sk_X509_OBJECT_num
  56.   
  57.   DEFINE_STACK_OF(X509_LOOKUP)
  58. > DEFINE_STACK_OF(X509_OBJECT)
  59.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  60.   

crypto/x509/x509_lu.c:468:30: Loop condition is true. Entering loop body
466.           *pnmatch = 1;
467.           pstmp = &stmp;
468.           for (tidx = idx + 1; tidx < sk_X509_OBJECT_num(h); tidx++) {
                                    ^
469.               tobj = sk_X509_OBJECT_value(h, tidx);
470.               if (x509_object_cmp(&tobj, &pstmp))

crypto/x509/x509_lu.c:469:13: 
467.           pstmp = &stmp;
468.           for (tidx = idx + 1; tidx < sk_X509_OBJECT_num(h); tidx++) {
469. >             tobj = sk_X509_OBJECT_value(h, tidx);
470.               if (x509_object_cmp(&tobj, &pstmp))
471.                   break;

include/openssl/x509_vfy.h:58:1: start of procedure sk_X509_OBJECT_value()
  56.   
  57.   DEFINE_STACK_OF(X509_LOOKUP)
  58. > DEFINE_STACK_OF(X509_OBJECT)
  59.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  60.   

crypto/stack/stack.c:272:1: start of procedure OPENSSL_sk_value()
    270.   }
    271.   
    272. > void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    273.   {
    274.       if (st == NULL || i < 0 || i >= st->num)

crypto/stack/stack.c:274:9: Taking false branch
    272.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    273.   {
    274.       if (st == NULL || i < 0 || i >= st->num)
                   ^
    275.           return NULL;
    276.       return st->data[i];

crypto/stack/stack.c:274:23: Taking true branch
    272.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    273.   {
    274.       if (st == NULL || i < 0 || i >= st->num)
                                 ^
    275.           return NULL;
    276.       return st->data[i];

crypto/stack/stack.c:275:9: 
    273.   {
    274.       if (st == NULL || i < 0 || i >= st->num)
    275. >         return NULL;
    276.       return st->data[i];
    277.   }

crypto/stack/stack.c:277:1: return from a call to OPENSSL_sk_value
    275.           return NULL;
    276.       return st->data[i];
    277. > }
    278.   
    279.   void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, void *value)

include/openssl/x509_vfy.h:58:1: return from a call to sk_X509_OBJECT_value
  56.   
  57.   DEFINE_STACK_OF(X509_LOOKUP)
  58. > DEFINE_STACK_OF(X509_OBJECT)
  59.   DEFINE_STACK_OF(X509_VERIFY_PARAM)
  60.   

crypto/x509/x509_lu.c:470:17: 
468.           for (tidx = idx + 1; tidx < sk_X509_OBJECT_num(h); tidx++) {
469.               tobj = sk_X509_OBJECT_value(h, tidx);
470. >             if (x509_object_cmp(&tobj, &pstmp))
471.                   break;
472.               (*pnmatch)++;

crypto/x509/x509_lu.c:120:1: start of procedure x509_object_cmp()
  118.   }
  119.   
  120. > static int x509_object_cmp(const X509_OBJECT *const *a,
  121.                              const X509_OBJECT *const *b)
  122.   {

crypto/x509/x509_lu.c:125:5: 
  123.       int ret;
  124.   
  125. >     ret = ((*a)->type - (*b)->type);
  126.       if (ret)
  127.           return ret;

static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type,
                               X509_NAME *name, int *pnmatch)
{
    X509_OBJECT stmp;
    X509 x509_s;
    X509_CRL crl_s;
    int idx;
    stmp.type = type;
    switch (type) {
    case X509_LU_X509:
        stmp.data.x509 = &x509_s;
        x509_s.cert_info.subject = name;
        break;
    case X509_LU_CRL:
        stmp.data.crl = &crl_s;
        crl_s.crl.issuer = name;
        break;
    default:
        return -1;
    }
    idx = sk_X509_OBJECT_find(h, &stmp);
    if (idx >= 0 && pnmatch) {
        int tidx;
        const X509_OBJECT *tobj, *pstmp;
        *pnmatch = 1;
        pstmp = &stmp;
        for (tidx = idx + 1; tidx < sk_X509_OBJECT_num(h); tidx++) {
            tobj = sk_X509_OBJECT_value(h, tidx);
            if (x509_object_cmp(&tobj, &pstmp))
                break;
            (*pnmatch)++;
        }
    }
    return idx;
}
['static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type,\n                               X509_NAME *name, int *pnmatch)\n{\n    X509_OBJECT stmp;\n    X509 x509_s;\n    X509_CRL crl_s;\n    int idx;\n    stmp.type = type;\n    switch (type) {\n    case X509_LU_X509:\n        stmp.data.x509 = &x509_s;\n        x509_s.cert_info.subject = name;\n        break;\n    case X509_LU_CRL:\n        stmp.data.crl = &crl_s;\n        crl_s.crl.issuer = name;\n        break;\n    default:\n        return -1;\n    }\n    idx = sk_X509_OBJECT_find(h, &stmp);\n    if (idx >= 0 && pnmatch) {\n        int tidx;\n        const X509_OBJECT *tobj, *pstmp;\n        *pnmatch = 1;\n        pstmp = &stmp;\n        for (tidx = idx + 1; tidx < sk_X509_OBJECT_num(h); tidx++) {\n            tobj = sk_X509_OBJECT_value(h, tidx);\n            if (x509_object_cmp(&tobj, &pstmp))\n                break;\n            (*pnmatch)++;\n        }\n    }\n    return idx;\n}', 'int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)\n{\n    return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);\n}', 'static int internal_find(OPENSSL_STACK *st, const void *data,\n                         int ret_val_options)\n{\n    const void *const *r;\n    int i;\n    if (st == NULL)\n        return -1;\n    if (st->comp == NULL) {\n        for (i = 0; i < st->num; i++)\n            if (st->data[i] == data)\n                return (i);\n        return (-1);\n    }\n    OPENSSL_sk_sort(st);\n    if (data == NULL)\n        return (-1);\n    r = OBJ_bsearch_ex_(&data, st->data, st->num, sizeof(void *), st->comp,\n                        ret_val_options);\n    if (r == NULL)\n        return (-1);\n    return (int)((char **)r - st->data);\n}', 'int OPENSSL_sk_num(const OPENSSL_STACK *st)\n{\n    if (st == NULL)\n        return -1;\n    return st->num;\n}', 'void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)\n{\n    if (st == NULL || i < 0 || i >= st->num)\n        return NULL;\n    return st->data[i];\n}', 'static int x509_object_cmp(const X509_OBJECT *const *a,\n                           const X509_OBJECT *const *b)\n{\n    int ret;\n    ret = ((*a)->type - (*b)->type);\n    if (ret)\n        return ret;\n    switch ((*a)->type) {\n    case X509_LU_X509:\n        ret = X509_subject_name_cmp((*a)->data.x509, (*b)->data.x509);\n        break;\n    case X509_LU_CRL:\n        ret = X509_CRL_cmp((*a)->data.crl, (*b)->data.crl);\n        break;\n    default:\n        return 0;\n    }\n    return ret;\n}']