crypto/x509/x509_lu.c:640: error: NULL_DEREFERENCE
  pointer `pobj` last assigned on line 638 could be null and is dereferenced at line 640, column 17.
Showing all 45 steps of the trace


crypto/x509/x509_lu.c:601:1: start of procedure X509_STORE_CTX_get1_issuer()
599.    * -1 some other error.
600.    */
601. > int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)
602.   {
603.       X509_NAME *xn;

crypto/x509/x509_lu.c:606:5: 
604.       X509_OBJECT obj, *pobj;
605.       int i, ok, idx, ret;
606. >     *issuer = NULL;
607.       xn = X509_get_issuer_name(x);
608.       ok = X509_STORE_get_by_subject(ctx, X509_LU_X509, xn, &obj);

crypto/x509/x509_lu.c:607:5: 
605.       int i, ok, idx, ret;
606.       *issuer = NULL;
607. >     xn = X509_get_issuer_name(x);
608.       ok = X509_STORE_get_by_subject(ctx, X509_LU_X509, xn, &obj);
609.       if (ok != X509_LU_X509) {

crypto/x509/x509_cmp.c:131:1: start of procedure X509_get_issuer_name()
  129.   }
  130.   
  131. > X509_NAME *X509_get_issuer_name(X509 *a)
  132.   {
  133.       return (a->cert_info.issuer);

crypto/x509/x509_cmp.c:133:5: 
  131.   X509_NAME *X509_get_issuer_name(X509 *a)
  132.   {
  133. >     return (a->cert_info.issuer);
  134.   }
  135.   

crypto/x509/x509_cmp.c:134:1: return from a call to X509_get_issuer_name
  132.   {
  133.       return (a->cert_info.issuer);
  134. > }
  135.   
  136.   unsigned long X509_issuer_name_hash(X509 *x)

crypto/x509/x509_lu.c:608:5: Skipping X509_STORE_get_by_subject(): empty list of specs
606.       *issuer = NULL;
607.       xn = X509_get_issuer_name(x);
608.       ok = X509_STORE_get_by_subject(ctx, X509_LU_X509, xn, &obj);
           ^
609.       if (ok != X509_LU_X509) {
610.           if (ok == X509_LU_RETRY) {

crypto/x509/x509_lu.c:609:9: Taking false branch
607.       xn = X509_get_issuer_name(x);
608.       ok = X509_STORE_get_by_subject(ctx, X509_LU_X509, xn, &obj);
609.       if (ok != X509_LU_X509) {
               ^
610.           if (ok == X509_LU_RETRY) {
611.               X509_OBJECT_free_contents(&obj);

crypto/x509/x509_lu.c:622:9: Taking false branch
620.       }
621.       /* If certificate matches all OK */
622.       if (ctx->check_issued(ctx, x, obj.data.x509)) {
               ^
623.           if (x509_check_cert_time(ctx, obj.data.x509, 1)) {
624.               *issuer = obj.data.x509;

crypto/x509/x509_lu.c:628:5: 
626.           }
627.       }
628. >     X509_OBJECT_free_contents(&obj);
629.   
630.       /* Else find index of first cert accepted by 'check_issued' */

crypto/x509/x509_lu.c:407:1: start of procedure X509_OBJECT_free_contents()
  405.   }
  406.   
  407. > void X509_OBJECT_free_contents(X509_OBJECT *a)
  408.   {
  409.       if (!a)

crypto/x509/x509_lu.c:409:10: Taking false branch
  407.   void X509_OBJECT_free_contents(X509_OBJECT *a)
  408.   {
  409.       if (!a)
                  ^
  410.           return;
  411.       switch (a->type) {

crypto/x509/x509_lu.c:411:5: 
  409.       if (!a)
  410.           return;
  411. >     switch (a->type) {
  412.       default:
  413.           break;

crypto/x509/x509_lu.c:414:5: Switch condition is false. Skipping switch case
  412.       default:
  413.           break;
  414.       case X509_LU_X509:
             ^
  415.           X509_free(a->data.x509);
  416.           break;

crypto/x509/x509_lu.c:417:5: Switch condition is false. Skipping switch case
  415.           X509_free(a->data.x509);
  416.           break;
  417.       case X509_LU_CRL:
             ^
  418.           X509_CRL_free(a->data.crl);
  419.           break;

crypto/x509/x509_lu.c:421:1: return from a call to X509_OBJECT_free_contents
  419.           break;
  420.       }
  421. > }
  422.   
  423.   static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, int type,

crypto/x509/x509_lu.c:631:5: 
629.   
630.       /* Else find index of first cert accepted by 'check_issued' */
631. >     ret = 0;
632.       CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
633.       idx = X509_OBJECT_idx_by_subject(ctx->ctx->objs, X509_LU_X509, xn);

crypto/x509/x509_lu.c:632:5: 
630.       /* Else find index of first cert accepted by 'check_issued' */
631.       ret = 0;
632. >     CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
633.       idx = X509_OBJECT_idx_by_subject(ctx->ctx->objs, X509_LU_X509, xn);
634.       if (idx != -1) {            /* should be true as we've had at least one

crypto/lock.c:416:1: start of procedure CRYPTO_lock()
  414.   }
  415.   
  416. > void CRYPTO_lock(int mode, int type, const char *file, int line)
  417.   {
  418.   #ifdef LOCK_DEBUG

crypto/lock.c:443:9: Taking false branch
  441.       }
  442.   #endif
  443.       if (type < 0) {
                 ^
  444.           if (dynlock_lock_callback != NULL) {
  445.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:454:16: Taking true branch
  452.               CRYPTO_destroy_dynlockid(type);
  453.           }
  454.       } else if (locking_callback != NULL)
                        ^
  455.           locking_callback(mode, type, file, line);
  456.   }

crypto/lock.c:455:9: Skipping __function_pointer__(): unresolved function pointer
  453.           }
  454.       } else if (locking_callback != NULL)
  455.           locking_callback(mode, type, file, line);
                 ^
  456.   }
  457.   

crypto/lock.c:443:5: 
  441.       }
  442.   #endif
  443. >     if (type < 0) {
  444.           if (dynlock_lock_callback != NULL) {
  445.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:456:1: return from a call to CRYPTO_lock
  454.       } else if (locking_callback != NULL)
  455.           locking_callback(mode, type, file, line);
  456. > }
  457.   
  458.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/x509/x509_lu.c:633:5: 
631.       ret = 0;
632.       CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
633. >     idx = X509_OBJECT_idx_by_subject(ctx->ctx->objs, X509_LU_X509, xn);
634.       if (idx != -1) {            /* should be true as we've had at least one
635.                                    * match */

crypto/x509/x509_lu.c:462:1: start of procedure X509_OBJECT_idx_by_subject()
  460.   }
  461.   
  462. > int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,
  463.                                  X509_NAME *name)
  464.   {

crypto/x509/x509_lu.c:465:5: Skipping x509_object_idx_cnt(): empty list of specs
  463.                                  X509_NAME *name)
  464.   {
  465.       return x509_object_idx_cnt(h, type, name, NULL);
             ^
  466.   }
  467.   

crypto/x509/x509_lu.c:466:1: return from a call to X509_OBJECT_idx_by_subject
  464.   {
  465.       return x509_object_idx_cnt(h, type, name, NULL);
  466. > }
  467.   
  468.   X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,

crypto/x509/x509_lu.c:634:9: Taking true branch
632.       CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
633.       idx = X509_OBJECT_idx_by_subject(ctx->ctx->objs, X509_LU_X509, xn);
634.       if (idx != -1) {            /* should be true as we've had at least one
               ^
635.                                    * match */
636.           /* Look through all matching certs for suitable issuer */

crypto/x509/x509_lu.c:637:14: 
635.                                    * match */
636.           /* Look through all matching certs for suitable issuer */
637. >         for (i = idx; i < sk_X509_OBJECT_num(ctx->ctx->objs); i++) {
638.               pobj = sk_X509_OBJECT_value(ctx->ctx->objs, i);
639.               /* See if we've run past the matches */

crypto/x509/x509_lu.c:637:27: Condition is true
635.                                    * match */
636.           /* Look through all matching certs for suitable issuer */
637.           for (i = idx; i < sk_X509_OBJECT_num(ctx->ctx->objs); i++) {
                                 ^
638.               pobj = sk_X509_OBJECT_value(ctx->ctx->objs, i);
639.               /* See if we've run past the matches */

crypto/x509/x509_lu.c:637:23: 
635.                                    * match */
636.           /* Look through all matching certs for suitable issuer */
637. >         for (i = idx; i < sk_X509_OBJECT_num(ctx->ctx->objs); i++) {
638.               pobj = sk_X509_OBJECT_value(ctx->ctx->objs, i);
639.               /* See if we've run past the matches */

crypto/stack/stack.c:317:1: start of procedure sk_num()
  315.   }
  316.   
  317. > int sk_num(const _STACK *st)
  318.   {
  319.       if (st == NULL)

crypto/stack/stack.c:319:9: Taking false branch
  317.   int sk_num(const _STACK *st)
  318.   {
  319.       if (st == NULL)
                 ^
  320.           return -1;
  321.       return st->num;

crypto/stack/stack.c:321:5: 
  319.       if (st == NULL)
  320.           return -1;
  321. >     return st->num;
  322.   }
  323.   

crypto/stack/stack.c:322:1: return from a call to sk_num
  320.           return -1;
  321.       return st->num;
  322. > }
  323.   
  324.   void *sk_value(const _STACK *st, int i)

crypto/x509/x509_lu.c:637:23: Loop condition is true. Entering loop body
635.                                    * match */
636.           /* Look through all matching certs for suitable issuer */
637.           for (i = idx; i < sk_X509_OBJECT_num(ctx->ctx->objs); i++) {
                             ^
638.               pobj = sk_X509_OBJECT_value(ctx->ctx->objs, i);
639.               /* See if we've run past the matches */

crypto/x509/x509_lu.c:638:20: Condition is true
636.           /* Look through all matching certs for suitable issuer */
637.           for (i = idx; i < sk_X509_OBJECT_num(ctx->ctx->objs); i++) {
638.               pobj = sk_X509_OBJECT_value(ctx->ctx->objs, i);
                          ^
639.               /* See if we've run past the matches */
640.               if (pobj->type != X509_LU_X509)

crypto/x509/x509_lu.c:638:13: 
636.           /* Look through all matching certs for suitable issuer */
637.           for (i = idx; i < sk_X509_OBJECT_num(ctx->ctx->objs); i++) {
638. >             pobj = sk_X509_OBJECT_value(ctx->ctx->objs, i);
639.               /* See if we've run past the matches */
640.               if (pobj->type != X509_LU_X509)

crypto/stack/stack.c:324:1: start of procedure sk_value()
  322.   }
  323.   
  324. > void *sk_value(const _STACK *st, int i)
  325.   {
  326.       if (!st || (i < 0) || (i >= st->num))

crypto/stack/stack.c:326:10: Taking false branch
  324.   void *sk_value(const _STACK *st, int i)
  325.   {
  326.       if (!st || (i < 0) || (i >= st->num))
                  ^
  327.           return NULL;
  328.       return st->data[i];

crypto/stack/stack.c:326:17: Taking true branch
  324.   void *sk_value(const _STACK *st, int i)
  325.   {
  326.       if (!st || (i < 0) || (i >= st->num))
                         ^
  327.           return NULL;
  328.       return st->data[i];

crypto/stack/stack.c:327:9: 
  325.   {
  326.       if (!st || (i < 0) || (i >= st->num))
  327. >         return NULL;
  328.       return st->data[i];
  329.   }

crypto/stack/stack.c:329:1: return from a call to sk_value
  327.           return NULL;
  328.       return st->data[i];
  329. > }
  330.   
  331.   void *sk_set(_STACK *st, int i, void *value)

crypto/x509/x509_lu.c:640:17: 
638.               pobj = sk_X509_OBJECT_value(ctx->ctx->objs, i);
639.               /* See if we've run past the matches */
640. >             if (pobj->type != X509_LU_X509)
641.                   break;
642.               if (X509_NAME_cmp(xn, X509_get_subject_name(pobj->data.x509)))

int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)
{
    X509_NAME *xn;
    X509_OBJECT obj, *pobj;
    int i, ok, idx, ret;
    *issuer = NULL;
    xn = X509_get_issuer_name(x);
    ok = X509_STORE_get_by_subject(ctx, X509_LU_X509, xn, &obj);
    if (ok != X509_LU_X509) {
        if (ok == X509_LU_RETRY) {
            X509_OBJECT_free_contents(&obj);
            X509err(X509_F_X509_STORE_CTX_GET1_ISSUER, X509_R_SHOULD_RETRY);
            return -1;
        } else if (ok != X509_LU_FAIL) {
            X509_OBJECT_free_contents(&obj);
            return -1;
        }
        return 0;
    }
    if (ctx->check_issued(ctx, x, obj.data.x509)) {
        if (x509_check_cert_time(ctx, obj.data.x509, 1)) {
            *issuer = obj.data.x509;
            return 1;
        }
    }
    X509_OBJECT_free_contents(&obj);
    ret = 0;
    CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
    idx = X509_OBJECT_idx_by_subject(ctx->ctx->objs, X509_LU_X509, xn);
    if (idx != -1) {
        for (i = idx; i < sk_X509_OBJECT_num(ctx->ctx->objs); i++) {
            pobj = sk_X509_OBJECT_value(ctx->ctx->objs, i);
            if (pobj->type != X509_LU_X509)
                break;
            if (X509_NAME_cmp(xn, X509_get_subject_name(pobj->data.x509)))
                break;
            if (ctx->check_issued(ctx, x, pobj->data.x509)) {
                *issuer = pobj->data.x509;
                ret = 1;
                if (x509_check_cert_time(ctx, *issuer, 1))
                    break;
            }
        }
    }
    CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
    if (*issuer)
        X509_up_ref(*issuer);
    return ret;
}
['int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)\n{\n    X509_NAME *xn;\n    X509_OBJECT obj, *pobj;\n    int i, ok, idx, ret;\n    *issuer = NULL;\n    xn = X509_get_issuer_name(x);\n    ok = X509_STORE_get_by_subject(ctx, X509_LU_X509, xn, &obj);\n    if (ok != X509_LU_X509) {\n        if (ok == X509_LU_RETRY) {\n            X509_OBJECT_free_contents(&obj);\n            X509err(X509_F_X509_STORE_CTX_GET1_ISSUER, X509_R_SHOULD_RETRY);\n            return -1;\n        } else if (ok != X509_LU_FAIL) {\n            X509_OBJECT_free_contents(&obj);\n            return -1;\n        }\n        return 0;\n    }\n    if (ctx->check_issued(ctx, x, obj.data.x509)) {\n        if (x509_check_cert_time(ctx, obj.data.x509, 1)) {\n            *issuer = obj.data.x509;\n            return 1;\n        }\n    }\n    X509_OBJECT_free_contents(&obj);\n    ret = 0;\n    CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);\n    idx = X509_OBJECT_idx_by_subject(ctx->ctx->objs, X509_LU_X509, xn);\n    if (idx != -1) {\n        for (i = idx; i < sk_X509_OBJECT_num(ctx->ctx->objs); i++) {\n            pobj = sk_X509_OBJECT_value(ctx->ctx->objs, i);\n            if (pobj->type != X509_LU_X509)\n                break;\n            if (X509_NAME_cmp(xn, X509_get_subject_name(pobj->data.x509)))\n                break;\n            if (ctx->check_issued(ctx, x, pobj->data.x509)) {\n                *issuer = pobj->data.x509;\n                ret = 1;\n                if (x509_check_cert_time(ctx, *issuer, 1))\n                    break;\n            }\n        }\n    }\n    CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);\n    if (*issuer)\n        X509_up_ref(*issuer);\n    return ret;\n}', 'X509_NAME *X509_get_issuer_name(X509 *a)\n{\n    return (a->cert_info.issuer);\n}', 'void X509_OBJECT_free_contents(X509_OBJECT *a)\n{\n    if (!a)\n        return;\n    switch (a->type) {\n    default:\n        break;\n    case X509_LU_X509:\n        X509_free(a->data.x509);\n        break;\n    case X509_LU_CRL:\n        X509_CRL_free(a->data.crl);\n        break;\n    }\n}', 'void CRYPTO_lock(int mode, int type, const char *file, int line)\n{\n#ifdef LOCK_DEBUG\n    {\n        CRYPTO_THREADID id;\n        char *rw_text, *operation_text;\n        if (mode & CRYPTO_LOCK)\n            operation_text = "lock  ";\n        else if (mode & CRYPTO_UNLOCK)\n            operation_text = "unlock";\n        else\n            operation_text = "ERROR ";\n        if (mode & CRYPTO_READ)\n            rw_text = "r";\n        else if (mode & CRYPTO_WRITE)\n            rw_text = "w";\n        else\n            rw_text = "ERROR";\n        CRYPTO_THREADID_current(&id);\n        fprintf(stderr, "lock:%08lx:(%s)%s %-18s %s:%d\\n",\n                CRYPTO_THREADID_hash(&id), rw_text, operation_text,\n                CRYPTO_get_lock_name(type), file, line);\n    }\n#endif\n    if (type < 0) {\n        if (dynlock_lock_callback != NULL) {\n            struct CRYPTO_dynlock_value *pointer\n                = CRYPTO_get_dynlock_value(type);\n            OPENSSL_assert(pointer != NULL);\n            dynlock_lock_callback(mode, pointer, file, line);\n            CRYPTO_destroy_dynlockid(type);\n        }\n    } else if (locking_callback != NULL)\n        locking_callback(mode, type, file, line);\n}', 'int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,\n                               X509_NAME *name)\n{\n    return x509_object_idx_cnt(h, type, name, NULL);\n}', 'int sk_num(const _STACK *st)\n{\n    if (st == NULL)\n        return -1;\n    return st->num;\n}', 'void *sk_value(const _STACK *st, int i)\n{\n    if (!st || (i < 0) || (i >= st->num))\n        return NULL;\n    return st->data[i];\n}']