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.   
