crypto/x509/x509_vfy.c:410: error: NULL_DEREFERENCE
  pointer `x` last assigned on line 392 could be null and is dereferenced by call to `X509_check_ca()` at line 410, column 15.
Showing all 25 steps of the trace


crypto/x509/x509_vfy.c:352:1: start of procedure check_chain_extensions()
350.    */
351.   
352. > static int check_chain_extensions(X509_STORE_CTX *ctx)
353.   {
354.       int i, ok = 0, must_be_ca, plen = 0;

crypto/x509/x509_vfy.c:354:5: 
352.   static int check_chain_extensions(X509_STORE_CTX *ctx)
353.   {
354. >     int i, ok = 0, must_be_ca, plen = 0;
355.       X509 *x;
356.       int (*cb) (int xok, X509_STORE_CTX *xctx);

crypto/x509/x509_vfy.c:357:5: 
355.       X509 *x;
356.       int (*cb) (int xok, X509_STORE_CTX *xctx);
357. >     int proxy_path_length = 0;
358.       int purpose;
359.       int allow_proxy_certs;

crypto/x509/x509_vfy.c:360:5: 
358.       int purpose;
359.       int allow_proxy_certs;
360. >     cb = ctx->verify_cb;
361.   
362.       /*-

crypto/x509/x509_vfy.c:371:5: 
369.        *     all certificates in the chain except the leaf certificate.
370.        */
371. >     must_be_ca = -1;
372.   
373.       /* CRL path validation */

crypto/x509/x509_vfy.c:374:9: Taking false branch
372.   
373.       /* CRL path validation */
374.       if (ctx->parent) {
               ^
375.           allow_proxy_certs = 0;
376.           purpose = X509_PURPOSE_CRL_SIGN;

crypto/x509/x509_vfy.c:379:17: Condition is true
377.       } else {
378.           allow_proxy_certs =
379.               ! !(ctx->param->flags & X509_V_FLAG_ALLOW_PROXY_CERTS);
                       ^
380.           /*
381.            * A hack to keep people who don't want to modify their software

crypto/x509/x509_vfy.c:379:13: 
377.       } else {
378.           allow_proxy_certs =
379. >             ! !(ctx->param->flags & X509_V_FLAG_ALLOW_PROXY_CERTS);
380.           /*
381.            * A hack to keep people who don't want to modify their software

crypto/x509/x509_vfy.c:378:9: 
376.           purpose = X509_PURPOSE_CRL_SIGN;
377.       } else {
378. >         allow_proxy_certs =
379.               ! !(ctx->param->flags & X509_V_FLAG_ALLOW_PROXY_CERTS);
380.           /*

crypto/x509/x509_vfy.c:384:13: Taking false branch
382.            * happy
383.            */
384.           if (getenv("OPENSSL_ALLOW_PROXY_CERTS"))
                   ^
385.               allow_proxy_certs = 1;
386.           purpose = ctx->param->purpose;

crypto/x509/x509_vfy.c:386:9: 
384.           if (getenv("OPENSSL_ALLOW_PROXY_CERTS"))
385.               allow_proxy_certs = 1;
386. >         purpose = ctx->param->purpose;
387.       }
388.   

crypto/x509/x509_vfy.c:390:10: 
388.   
389.       /* Check all untrusted certificates */
390. >     for (i = 0; i == 0 || i < ctx->num_untrusted; i++) {
391.           int ret;
392.           x = sk_X509_value(ctx->chain, i);

crypto/x509/x509_vfy.c:390:17: Loop condition is true. Entering loop body
388.   
389.       /* Check all untrusted certificates */
390.       for (i = 0; i == 0 || i < ctx->num_untrusted; i++) {
                       ^
391.           int ret;
392.           x = sk_X509_value(ctx->chain, i);

crypto/x509/x509_vfy.c:392:9: 
390.       for (i = 0; i == 0 || i < ctx->num_untrusted; i++) {
391.           int ret;
392. >         x = sk_X509_value(ctx->chain, i);
393.           if (!(ctx->param->flags & X509_V_FLAG_IGNORE_CRITICAL)
394.               && (x->ex_flags & EXFLAG_CRITICAL)) {

include/openssl/x509.h:170:1: start of procedure sk_X509_value()
  168.   typedef struct x509_cinf_st X509_CINF;
  169.   
  170. > DEFINE_STACK_OF(X509)
  171.   
  172.   /* This is used for a table of trust checking functions */

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 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)

include/openssl/x509.h:170:1: return from a call to sk_X509_value
  168.   typedef struct x509_cinf_st X509_CINF;
  169.   
  170. > DEFINE_STACK_OF(X509)
  171.   
  172.   /* This is used for a table of trust checking functions */

crypto/x509/x509_vfy.c:393:15: Taking false branch
391.           int ret;
392.           x = sk_X509_value(ctx->chain, i);
393.           if (!(ctx->param->flags & X509_V_FLAG_IGNORE_CRITICAL)
                     ^
394.               && (x->ex_flags & EXFLAG_CRITICAL)) {
395.               ctx->error = X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION;

crypto/x509/x509_vfy.c:402:14: Taking false branch
400.                   goto end;
401.           }
402.           if (!allow_proxy_certs && (x->ex_flags & EXFLAG_PROXY)) {
                    ^
403.               ctx->error = X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED;
404.               ctx->error_depth = i;

crypto/x509/x509_vfy.c:410:9: 
408.                   goto end;
409.           }
410. >         ret = X509_check_ca(x);
411.           switch (must_be_ca) {
412.           case -1:

crypto/x509v3/v3_purp.c:576:1: start of procedure X509_check_ca()
  574.   }
  575.   
  576. > int X509_check_ca(X509 *x)
  577.   {
  578.       if (!(x->ex_flags & EXFLAG_SET)) {

crypto/x509v3/v3_purp.c:578:11: 
  576.   int X509_check_ca(X509 *x)
  577.   {
  578. >     if (!(x->ex_flags & EXFLAG_SET)) {
  579.           CRYPTO_w_lock(CRYPTO_LOCK_X509);
  580.           x509v3_cache_extensions(x);
