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


apps/opt.c:435:1: start of procedure opt_verify()
433.   enum range { OPT_V_ENUM };
434.   
435. > int opt_verify(int opt, X509_VERIFY_PARAM *vpm)
436.   {
437.       int i;

apps/opt.c:438:5: 
436.   {
437.       int i;
438. >     ossl_intmax_t t = 0;
439.       ASN1_OBJECT *otmp;
440.       X509_PURPOSE *xptmp;

apps/opt.c:443:5: 
441.       const X509_VERIFY_PARAM *vtmp;
442.   
443. >     assert(vpm != NULL);
444.       assert(opt > OPT_V__FIRST);
445.       assert(opt < OPT_V__LAST);

apps/opt.c:444:5: 
442.   
443.       assert(vpm != NULL);
444. >     assert(opt > OPT_V__FIRST);
445.       assert(opt < OPT_V__LAST);
446.   

apps/opt.c:445:5: 
443.       assert(vpm != NULL);
444.       assert(opt > OPT_V__FIRST);
445. >     assert(opt < OPT_V__LAST);
446.   
447.       switch ((enum range)opt) {

apps/opt.c:447:5: 
445.       assert(opt < OPT_V__LAST);
446.   
447. >     switch ((enum range)opt) {
448.       case OPT_V__FIRST:
449.       case OPT_V__LAST:

apps/opt.c:448:5: Switch condition is false. Skipping switch case
446.   
447.       switch ((enum range)opt) {
448.       case OPT_V__FIRST:
           ^
449.       case OPT_V__LAST:
450.           return 0;

apps/opt.c:449:5: Switch condition is false. Skipping switch case
447.       switch ((enum range)opt) {
448.       case OPT_V__FIRST:
449.       case OPT_V__LAST:
           ^
450.           return 0;
451.       case OPT_V_POLICY:

apps/opt.c:451:5: Switch condition is false. Skipping switch case
449.       case OPT_V__LAST:
450.           return 0;
451.       case OPT_V_POLICY:
           ^
452.           otmp = OBJ_txt2obj(opt_arg(), 0);
453.           if (otmp == NULL) {

apps/opt.c:459:5: Switch condition is true. Entering switch case
457.           X509_VERIFY_PARAM_add0_policy(vpm, otmp);
458.           break;
459.       case OPT_V_PURPOSE:
           ^
460.           /* purpose name -> purpose index */
461.           i = X509_PURPOSE_get_by_sname(opt_arg());

apps/opt.c:461:9: 
459.       case OPT_V_PURPOSE:
460.           /* purpose name -> purpose index */
461. >         i = X509_PURPOSE_get_by_sname(opt_arg());
462.           if (i < 0) {
463.               BIO_printf(bio_err, "%s: Invalid purpose %s\n", prog, opt_arg());

apps/opt.c:747:1: start of procedure opt_arg()
  745.   
  746.   /* Return the most recent flag parameter. */
  747. > char *opt_arg(void)
  748.   {
  749.       return arg;

apps/opt.c:749:5: 
  747.   char *opt_arg(void)
  748.   {
  749. >     return arg;
  750.   }
  751.   

apps/opt.c:750:1: return from a call to opt_arg
  748.   {
  749.       return arg;
  750. > }
  751.   
  752.   /* Return the most recent flag. */

apps/opt.c:461:9: Skipping X509_PURPOSE_get_by_sname(): empty list of specs
459.       case OPT_V_PURPOSE:
460.           /* purpose name -> purpose index */
461.           i = X509_PURPOSE_get_by_sname(opt_arg());
               ^
462.           if (i < 0) {
463.               BIO_printf(bio_err, "%s: Invalid purpose %s\n", prog, opt_arg());

apps/opt.c:462:13: Taking false branch
460.           /* purpose name -> purpose index */
461.           i = X509_PURPOSE_get_by_sname(opt_arg());
462.           if (i < 0) {
                   ^
463.               BIO_printf(bio_err, "%s: Invalid purpose %s\n", prog, opt_arg());
464.               return 0;

apps/opt.c:468:9: 
466.   
467.           /* purpose index -> purpose object */
468. >         xptmp = X509_PURPOSE_get0(i);
469.   
470.           /* purpose object -> purpose value */

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

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

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

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

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

crypto/stack/stack.c:277:1: start of procedure OPENSSL_sk_value()
      275.   }
      276.   
      277. > void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
      278.   {
      279.       if (st == NULL || i < 0 || i >= st->num)

crypto/stack/stack.c:279:9: Taking true branch
      277.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
      278.   {
      279.       if (st == NULL || i < 0 || i >= st->num)
                     ^
      280.           return NULL;
      281.       return st->data[i];

crypto/stack/stack.c:280:9: 
      278.   {
      279.       if (st == NULL || i < 0 || i >= st->num)
      280. >         return NULL;
      281.       return st->data[i];
      282.   }

crypto/stack/stack.c:282:1: return from a call to OPENSSL_sk_value
      280.           return NULL;
      281.       return st->data[i];
      282. > }
      283.   
      284.   void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, void *value)

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

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

apps/opt.c:471:9: 
469.   
470.           /* purpose object -> purpose value */
471. >         i = X509_PURPOSE_get_id(xptmp);
472.   
473.           if (!X509_VERIFY_PARAM_set_purpose(vpm, i)) {

crypto/x509v3/v3_purp.c:239:1: start of procedure X509_PURPOSE_get_id()
  237.   }
  238.   
  239. > int X509_PURPOSE_get_id(const X509_PURPOSE *xp)
  240.   {
  241.       return xp->purpose;

crypto/x509v3/v3_purp.c:241:5: 
  239.   int X509_PURPOSE_get_id(const X509_PURPOSE *xp)
  240.   {
  241. >     return xp->purpose;
  242.   }
  243.   

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;
    assert(vpm != NULL);
    assert(opt > OPT_V__FIRST);
    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) {
            BIO_printf(bio_err, "%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) {
            BIO_printf(bio_err, "%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)) {
            BIO_printf(bio_err,
                       "%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) {
            BIO_printf(bio_err, "%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) {
            BIO_printf(bio_err, "%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;
    }
    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    assert(vpm != NULL);\n    assert(opt > OPT_V__FIRST);\n    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            BIO_printf(bio_err, "%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            BIO_printf(bio_err, "%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            BIO_printf(bio_err,\n                       "%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            BIO_printf(bio_err, "%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            BIO_printf(bio_err, "%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    }\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 st->data[i];\n}', 'int X509_PURPOSE_get_id(const X509_PURPOSE *xp)\n{\n    return xp->purpose;\n}']