apps/lib/opt.c:497: error: NULL_DEREFERENCE
  pointer `xptmp` last assigned on line 494 could be null and is dereferenced by call to `X509_PURPOSE_get_id()` at line 497, column 13.
Showing all 31 steps of the trace


apps/lib/opt.c:461:1: start of procedure opt_verify()
459.   enum range { OPT_V_ENUM };
460.   
461. > int opt_verify(int opt, X509_VERIFY_PARAM *vpm)
462.   {
463.       int i;

apps/lib/opt.c:464:5: 
462.   {
463.       int i;
464. >     ossl_intmax_t t = 0;
465.       ASN1_OBJECT *otmp;
466.       X509_PURPOSE *xptmp;

apps/lib/opt.c:469:5: Condition is true
467.       const X509_VERIFY_PARAM *vtmp;
468.   
469.       OPENSSL_assert(vpm != NULL);
           ^
470.       OPENSSL_assert(opt > OPT_V__FIRST);
471.       OPENSSL_assert(opt < OPT_V__LAST);

apps/lib/opt.c:470:5: Condition is true
468.   
469.       OPENSSL_assert(vpm != NULL);
470.       OPENSSL_assert(opt > OPT_V__FIRST);
           ^
471.       OPENSSL_assert(opt < OPT_V__LAST);
472.   

apps/lib/opt.c:471:5: Condition is true
469.       OPENSSL_assert(vpm != NULL);
470.       OPENSSL_assert(opt > OPT_V__FIRST);
471.       OPENSSL_assert(opt < OPT_V__LAST);
           ^
472.   
473.       switch ((enum range)opt) {

apps/lib/opt.c:473:5: 
471.       OPENSSL_assert(opt < OPT_V__LAST);
472.   
473. >     switch ((enum range)opt) {
474.       case OPT_V__FIRST:
475.       case OPT_V__LAST:

apps/lib/opt.c:474:5: Switch condition is false. Skipping switch case
472.   
473.       switch ((enum range)opt) {
474.       case OPT_V__FIRST:
           ^
475.       case OPT_V__LAST:
476.           return 0;

apps/lib/opt.c:475:5: Switch condition is false. Skipping switch case
473.       switch ((enum range)opt) {
474.       case OPT_V__FIRST:
475.       case OPT_V__LAST:
           ^
476.           return 0;
477.       case OPT_V_POLICY:

apps/lib/opt.c:477:5: Switch condition is false. Skipping switch case
475.       case OPT_V__LAST:
476.           return 0;
477.       case OPT_V_POLICY:
           ^
478.           otmp = OBJ_txt2obj(opt_arg(), 0);
479.           if (otmp == NULL) {

apps/lib/opt.c:485:5: Switch condition is true. Entering switch case
483.           X509_VERIFY_PARAM_add0_policy(vpm, otmp);
484.           break;
485.       case OPT_V_PURPOSE:
           ^
486.           /* purpose name -> purpose index */
487.           i = X509_PURPOSE_get_by_sname(opt_arg());

apps/lib/opt.c:487:9: 
485.       case OPT_V_PURPOSE:
486.           /* purpose name -> purpose index */
487. >         i = X509_PURPOSE_get_by_sname(opt_arg());
488.           if (i < 0) {
489.               opt_printf_stderr("%s: Invalid purpose %s\n", prog, opt_arg());

apps/lib/opt.c:766:1: start of procedure opt_arg()
  764.   
  765.   /* Return the most recent flag parameter. */
  766. > char *opt_arg(void)
  767.   {
  768.       return arg;

apps/lib/opt.c:768:5: 
  766.   char *opt_arg(void)
  767.   {
  768. >     return arg;
  769.   }
  770.   

apps/lib/opt.c:769:1: return from a call to opt_arg
  767.   {
  768.       return arg;
  769. > }
  770.   
  771.   /* Return the most recent flag. */

apps/lib/opt.c:487:9: Skipping X509_PURPOSE_get_by_sname(): empty list of specs
485.       case OPT_V_PURPOSE:
486.           /* purpose name -> purpose index */
487.           i = X509_PURPOSE_get_by_sname(opt_arg());
               ^
488.           if (i < 0) {
489.               opt_printf_stderr("%s: Invalid purpose %s\n", prog, opt_arg());

apps/lib/opt.c:488:13: Taking false branch
486.           /* purpose name -> purpose index */
487.           i = X509_PURPOSE_get_by_sname(opt_arg());
488.           if (i < 0) {
                   ^
489.               opt_printf_stderr("%s: Invalid purpose %s\n", prog, opt_arg());
490.               return 0;

apps/lib/opt.c:494:9: 
492.   
493.           /* purpose index -> purpose object */
494. >         xptmp = X509_PURPOSE_get0(i);
495.   
496.           /* purpose object -> purpose value */

crypto/x509/v3_purp.c:112:1: start of procedure X509_PURPOSE_get0()
  110.   }
  111.   
  112. > X509_PURPOSE *X509_PURPOSE_get0(int idx)
  113.   {
  114.       if (idx < 0)

crypto/x509/v3_purp.c:114:9: Taking false branch
  112.   X509_PURPOSE *X509_PURPOSE_get0(int idx)
  113.   {
  114.       if (idx < 0)
                 ^
  115.           return NULL;
  116.       if (idx < (int)X509_PURPOSE_COUNT)

crypto/x509/v3_purp.c:116:9: Taking false branch
  114.       if (idx < 0)
  115.           return NULL;
  116.       if (idx < (int)X509_PURPOSE_COUNT)
                 ^
  117.           return xstandard + idx;
  118.       return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);

crypto/x509/v3_purp.c:118:5: 
  116.       if (idx < (int)X509_PURPOSE_COUNT)
  117.           return xstandard + idx;
  118. >     return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);
  119.   }
  120.   

include/openssl/x509v3.h:448:1: start of procedure sk_X509_PURPOSE_value()
    446.   # define X509V3_ADD_SILENT               0x10
    447.   
    448. > DEFINE_STACK_OF(X509_PURPOSE)
    449.   
    450.   DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)

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

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

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

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

include/openssl/x509v3.h:448:1: return from a call to sk_X509_PURPOSE_value
    446.   # define X509V3_ADD_SILENT               0x10
    447.   
    448. > DEFINE_STACK_OF(X509_PURPOSE)
    449.   
    450.   DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)

crypto/x509/v3_purp.c:119:1: return from a call to X509_PURPOSE_get0
  117.           return xstandard + idx;
  118.       return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);
  119. > }
  120.   
  121.   int X509_PURPOSE_get_by_sname(const char *sname)

apps/lib/opt.c:497:9: 
495.   
496.           /* purpose object -> purpose value */
497. >         i = X509_PURPOSE_get_id(xptmp);
498.   
499.           if (!X509_VERIFY_PARAM_set_purpose(vpm, i)) {

crypto/x509/v3_purp.c:236:1: start of procedure X509_PURPOSE_get_id()
  234.   }
  235.   
  236. > int X509_PURPOSE_get_id(const X509_PURPOSE *xp)
  237.   {
  238.       return xp->purpose;

crypto/x509/v3_purp.c:238:5: 
  236.   int X509_PURPOSE_get_id(const X509_PURPOSE *xp)
  237.   {
  238. >     return xp->purpose;
  239.   }
  240.   

int opt_verify(int opt, X509_VERIFY_PARAM *vpm)
{
    int i;
    ossl_intmax_t t = 0;
    ASN1_OBJECT *otmp;
    X509_PURPOSE *xptmp;
    const X509_VERIFY_PARAM *vtmp;
    OPENSSL_assert(vpm != NULL);
    OPENSSL_assert(opt > OPT_V__FIRST);
    OPENSSL_assert(opt < OPT_V__LAST);
    switch ((enum range)opt) {
    case OPT_V__FIRST:
    case OPT_V__LAST:
        return 0;
    case OPT_V_POLICY:
        otmp = OBJ_txt2obj(opt_arg(), 0);
        if (otmp == NULL) {
            opt_printf_stderr("%s: Invalid Policy %s\n", prog, opt_arg());
            return 0;
        }
        X509_VERIFY_PARAM_add0_policy(vpm, otmp);
        break;
    case OPT_V_PURPOSE:
        i = X509_PURPOSE_get_by_sname(opt_arg());
        if (i < 0) {
            opt_printf_stderr("%s: Invalid purpose %s\n", prog, opt_arg());
            return 0;
        }
        xptmp = X509_PURPOSE_get0(i);
        i = X509_PURPOSE_get_id(xptmp);
        if (!X509_VERIFY_PARAM_set_purpose(vpm, i)) {
            opt_printf_stderr("%s: Internal error setting purpose %s\n",
                              prog, opt_arg());
            return 0;
        }
        break;
    case OPT_V_VERIFY_NAME:
        vtmp = X509_VERIFY_PARAM_lookup(opt_arg());
        if (vtmp == NULL) {
            opt_printf_stderr("%s: Invalid verify name %s\n",
                              prog, opt_arg());
            return 0;
        }
        X509_VERIFY_PARAM_set1(vpm, vtmp);
        break;
    case OPT_V_VERIFY_DEPTH:
        i = atoi(opt_arg());
        if (i >= 0)
            X509_VERIFY_PARAM_set_depth(vpm, i);
        break;
    case OPT_V_VERIFY_AUTH_LEVEL:
        i = atoi(opt_arg());
        if (i >= 0)
            X509_VERIFY_PARAM_set_auth_level(vpm, i);
        break;
    case OPT_V_ATTIME:
        if (!opt_imax(opt_arg(), &t))
            return 0;
        if (t != (time_t)t) {
            opt_printf_stderr("%s: epoch time out of range %s\n",
                              prog, opt_arg());
            return 0;
        }
        X509_VERIFY_PARAM_set_time(vpm, (time_t)t);
        break;
    case OPT_V_VERIFY_HOSTNAME:
        if (!X509_VERIFY_PARAM_set1_host(vpm, opt_arg(), 0))
            return 0;
        break;
    case OPT_V_VERIFY_EMAIL:
        if (!X509_VERIFY_PARAM_set1_email(vpm, opt_arg(), 0))
            return 0;
        break;
    case OPT_V_VERIFY_IP:
        if (!X509_VERIFY_PARAM_set1_ip_asc(vpm, opt_arg()))
            return 0;
        break;
    case OPT_V_IGNORE_CRITICAL:
        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_IGNORE_CRITICAL);
        break;
    case OPT_V_ISSUER_CHECKS:
        break;
    case OPT_V_CRL_CHECK:
        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_CRL_CHECK);
        break;
    case OPT_V_CRL_CHECK_ALL:
        X509_VERIFY_PARAM_set_flags(vpm,
                                    X509_V_FLAG_CRL_CHECK |
                                    X509_V_FLAG_CRL_CHECK_ALL);
        break;
    case OPT_V_POLICY_CHECK:
        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_POLICY_CHECK);
        break;
    case OPT_V_EXPLICIT_POLICY:
        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_EXPLICIT_POLICY);
        break;
    case OPT_V_INHIBIT_ANY:
        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_INHIBIT_ANY);
        break;
    case OPT_V_INHIBIT_MAP:
        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_INHIBIT_MAP);
        break;
    case OPT_V_X509_STRICT:
        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_X509_STRICT);
        break;
    case OPT_V_EXTENDED_CRL:
        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_EXTENDED_CRL_SUPPORT);
        break;
    case OPT_V_USE_DELTAS:
        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_USE_DELTAS);
        break;
    case OPT_V_POLICY_PRINT:
        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_NOTIFY_POLICY);
        break;
    case OPT_V_CHECK_SS_SIG:
        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_CHECK_SS_SIGNATURE);
        break;
    case OPT_V_TRUSTED_FIRST:
        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_TRUSTED_FIRST);
        break;
    case OPT_V_SUITEB_128_ONLY:
        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_SUITEB_128_LOS_ONLY);
        break;
    case OPT_V_SUITEB_128:
        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_SUITEB_128_LOS);
        break;
    case OPT_V_SUITEB_192:
        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_SUITEB_192_LOS);
        break;
    case OPT_V_PARTIAL_CHAIN:
        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_PARTIAL_CHAIN);
        break;
    case OPT_V_NO_ALT_CHAINS:
        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_NO_ALT_CHAINS);
        break;
    case OPT_V_NO_CHECK_TIME:
        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_NO_CHECK_TIME);
        break;
    case OPT_V_ALLOW_PROXY_CERTS:
        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_ALLOW_PROXY_CERTS);
        break;
    }
    return 1;
}
['int opt_verify(int opt, X509_VERIFY_PARAM *vpm)\n{\n    int i;\n    ossl_intmax_t t = 0;\n    ASN1_OBJECT *otmp;\n    X509_PURPOSE *xptmp;\n    const X509_VERIFY_PARAM *vtmp;\n    OPENSSL_assert(vpm != NULL);\n    OPENSSL_assert(opt > OPT_V__FIRST);\n    OPENSSL_assert(opt < OPT_V__LAST);\n    switch ((enum range)opt) {\n    case OPT_V__FIRST:\n    case OPT_V__LAST:\n        return 0;\n    case OPT_V_POLICY:\n        otmp = OBJ_txt2obj(opt_arg(), 0);\n        if (otmp == NULL) {\n            opt_printf_stderr("%s: Invalid Policy %s\\n", prog, opt_arg());\n            return 0;\n        }\n        X509_VERIFY_PARAM_add0_policy(vpm, otmp);\n        break;\n    case OPT_V_PURPOSE:\n        i = X509_PURPOSE_get_by_sname(opt_arg());\n        if (i < 0) {\n            opt_printf_stderr("%s: Invalid purpose %s\\n", prog, opt_arg());\n            return 0;\n        }\n        xptmp = X509_PURPOSE_get0(i);\n        i = X509_PURPOSE_get_id(xptmp);\n        if (!X509_VERIFY_PARAM_set_purpose(vpm, i)) {\n            opt_printf_stderr("%s: Internal error setting purpose %s\\n",\n                              prog, opt_arg());\n            return 0;\n        }\n        break;\n    case OPT_V_VERIFY_NAME:\n        vtmp = X509_VERIFY_PARAM_lookup(opt_arg());\n        if (vtmp == NULL) {\n            opt_printf_stderr("%s: Invalid verify name %s\\n",\n                              prog, opt_arg());\n            return 0;\n        }\n        X509_VERIFY_PARAM_set1(vpm, vtmp);\n        break;\n    case OPT_V_VERIFY_DEPTH:\n        i = atoi(opt_arg());\n        if (i >= 0)\n            X509_VERIFY_PARAM_set_depth(vpm, i);\n        break;\n    case OPT_V_VERIFY_AUTH_LEVEL:\n        i = atoi(opt_arg());\n        if (i >= 0)\n            X509_VERIFY_PARAM_set_auth_level(vpm, i);\n        break;\n    case OPT_V_ATTIME:\n        if (!opt_imax(opt_arg(), &t))\n            return 0;\n        if (t != (time_t)t) {\n            opt_printf_stderr("%s: epoch time out of range %s\\n",\n                              prog, opt_arg());\n            return 0;\n        }\n        X509_VERIFY_PARAM_set_time(vpm, (time_t)t);\n        break;\n    case OPT_V_VERIFY_HOSTNAME:\n        if (!X509_VERIFY_PARAM_set1_host(vpm, opt_arg(), 0))\n            return 0;\n        break;\n    case OPT_V_VERIFY_EMAIL:\n        if (!X509_VERIFY_PARAM_set1_email(vpm, opt_arg(), 0))\n            return 0;\n        break;\n    case OPT_V_VERIFY_IP:\n        if (!X509_VERIFY_PARAM_set1_ip_asc(vpm, opt_arg()))\n            return 0;\n        break;\n    case OPT_V_IGNORE_CRITICAL:\n        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_IGNORE_CRITICAL);\n        break;\n    case OPT_V_ISSUER_CHECKS:\n        break;\n    case OPT_V_CRL_CHECK:\n        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_CRL_CHECK);\n        break;\n    case OPT_V_CRL_CHECK_ALL:\n        X509_VERIFY_PARAM_set_flags(vpm,\n                                    X509_V_FLAG_CRL_CHECK |\n                                    X509_V_FLAG_CRL_CHECK_ALL);\n        break;\n    case OPT_V_POLICY_CHECK:\n        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_POLICY_CHECK);\n        break;\n    case OPT_V_EXPLICIT_POLICY:\n        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_EXPLICIT_POLICY);\n        break;\n    case OPT_V_INHIBIT_ANY:\n        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_INHIBIT_ANY);\n        break;\n    case OPT_V_INHIBIT_MAP:\n        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_INHIBIT_MAP);\n        break;\n    case OPT_V_X509_STRICT:\n        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_X509_STRICT);\n        break;\n    case OPT_V_EXTENDED_CRL:\n        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_EXTENDED_CRL_SUPPORT);\n        break;\n    case OPT_V_USE_DELTAS:\n        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_USE_DELTAS);\n        break;\n    case OPT_V_POLICY_PRINT:\n        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_NOTIFY_POLICY);\n        break;\n    case OPT_V_CHECK_SS_SIG:\n        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_CHECK_SS_SIGNATURE);\n        break;\n    case OPT_V_TRUSTED_FIRST:\n        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_TRUSTED_FIRST);\n        break;\n    case OPT_V_SUITEB_128_ONLY:\n        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_SUITEB_128_LOS_ONLY);\n        break;\n    case OPT_V_SUITEB_128:\n        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_SUITEB_128_LOS);\n        break;\n    case OPT_V_SUITEB_192:\n        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_SUITEB_192_LOS);\n        break;\n    case OPT_V_PARTIAL_CHAIN:\n        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_PARTIAL_CHAIN);\n        break;\n    case OPT_V_NO_ALT_CHAINS:\n        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_NO_ALT_CHAINS);\n        break;\n    case OPT_V_NO_CHECK_TIME:\n        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_NO_CHECK_TIME);\n        break;\n    case OPT_V_ALLOW_PROXY_CERTS:\n        X509_VERIFY_PARAM_set_flags(vpm, X509_V_FLAG_ALLOW_PROXY_CERTS);\n        break;\n    }\n    return 1;\n}', 'char *opt_arg(void)\n{\n    return arg;\n}', 'X509_PURPOSE *X509_PURPOSE_get0(int idx)\n{\n    if (idx < 0)\n        return NULL;\n    if (idx < (int)X509_PURPOSE_COUNT)\n        return xstandard + idx;\n    return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);\n}', 'DEFINE_STACK_OF(X509_PURPOSE)', '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 (void *)st->data[i];\n}', 'int X509_PURPOSE_get_id(const X509_PURPOSE *xp)\n{\n    return xp->purpose;\n}']