crypto/x509/x509_vfy.c:859: error: NULL_DEREFERENCE
  pointer `x` last assigned on line 847 could be null and is dereferenced by call to `get_crl_delta()` at line 859, column 9.
Showing all 26 steps of the trace


crypto/x509/x509_vfy.c:840:1: start of procedure check_cert()
838.   	}
839.   
840. > static int check_cert(X509_STORE_CTX *ctx)
841.   	{
842.   	X509_CRL *crl = NULL, *dcrl = NULL;

crypto/x509/x509_vfy.c:842:2: 
840.   static int check_cert(X509_STORE_CTX *ctx)
841.   	{
842. > 	X509_CRL *crl = NULL, *dcrl = NULL;
843.   	X509 *x;
844.   	int ok, cnum;

crypto/x509/x509_vfy.c:846:2: 
844.   	int ok, cnum;
845.   	unsigned int last_reasons;
846. > 	cnum = ctx->error_depth;
847.   	x = sk_X509_value(ctx->chain, cnum);
848.   	ctx->current_cert = x;

crypto/x509/x509_vfy.c:847:6: Condition is true
845.   	unsigned int last_reasons;
846.   	cnum = ctx->error_depth;
847.   	x = sk_X509_value(ctx->chain, cnum);
            ^
848.   	ctx->current_cert = x;
849.   	ctx->current_issuer = NULL;

crypto/x509/x509_vfy.c:847:2: 
845.   	unsigned int last_reasons;
846.   	cnum = ctx->error_depth;
847. > 	x = sk_X509_value(ctx->chain, cnum);
848.   	ctx->current_cert = x;
849.   	ctx->current_issuer = NULL;

crypto/stack/stack.c:300:1: start of procedure sk_value()
  298.   }
  299.   
  300. > void *sk_value(const _STACK *st, int i)
  301.   {
  302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;

crypto/stack/stack.c:302:6: Taking false branch
  300.   void *sk_value(const _STACK *st, int i)
  301.   {
  302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
              ^
  303.   	return st->data[i];
  304.   }

crypto/stack/stack.c:302:13: Taking false branch
  300.   void *sk_value(const _STACK *st, int i)
  301.   {
  302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                     ^
  303.   	return st->data[i];
  304.   }

crypto/stack/stack.c:302:24: Taking true branch
  300.   void *sk_value(const _STACK *st, int i)
  301.   {
  302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                                ^
  303.   	return st->data[i];
  304.   }

crypto/stack/stack.c:302:39: 
  300.   void *sk_value(const _STACK *st, int i)
  301.   {
  302. > 	if(!st || (i < 0) || (i >= st->num)) return NULL;
  303.   	return st->data[i];
  304.   }

crypto/stack/stack.c:304:1: return from a call to sk_value
  302.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
  303.   	return st->data[i];
  304. > }
  305.   
  306.   void *sk_set(_STACK *st, int i, void *value)

crypto/x509/x509_vfy.c:848:2: 
846.   	cnum = ctx->error_depth;
847.   	x = sk_X509_value(ctx->chain, cnum);
848. > 	ctx->current_cert = x;
849.   	ctx->current_issuer = NULL;
850.   	ctx->current_crl_score = 0;

crypto/x509/x509_vfy.c:849:2: 
847.   	x = sk_X509_value(ctx->chain, cnum);
848.   	ctx->current_cert = x;
849. > 	ctx->current_issuer = NULL;
850.   	ctx->current_crl_score = 0;
851.   	ctx->current_reasons = 0;

crypto/x509/x509_vfy.c:850:2: 
848.   	ctx->current_cert = x;
849.   	ctx->current_issuer = NULL;
850. > 	ctx->current_crl_score = 0;
851.   	ctx->current_reasons = 0;
852.   	while (ctx->current_reasons != CRLDP_ALL_REASONS)

crypto/x509/x509_vfy.c:851:2: 
849.   	ctx->current_issuer = NULL;
850.   	ctx->current_crl_score = 0;
851. > 	ctx->current_reasons = 0;
852.   	while (ctx->current_reasons != CRLDP_ALL_REASONS)
853.   		{

crypto/x509/x509_vfy.c:852:9: Loop condition is true. Entering loop body
850.   	ctx->current_crl_score = 0;
851.   	ctx->current_reasons = 0;
852.   	while (ctx->current_reasons != CRLDP_ALL_REASONS)
               ^
853.   		{
854.   		last_reasons = ctx->current_reasons;

crypto/x509/x509_vfy.c:854:3: 
852.   	while (ctx->current_reasons != CRLDP_ALL_REASONS)
853.   		{
854. > 		last_reasons = ctx->current_reasons;
855.   		/* Try to retrieve relevant CRL */
856.   		if (ctx->get_crl)

crypto/x509/x509_vfy.c:856:7: Taking false branch
854.   		last_reasons = ctx->current_reasons;
855.   		/* Try to retrieve relevant CRL */
856.   		if (ctx->get_crl)
             ^
857.   			ok = ctx->get_crl(ctx, &crl, x);
858.   		else

crypto/x509/x509_vfy.c:859:4: 
857.   			ok = ctx->get_crl(ctx, &crl, x);
858.   		else
859. > 			ok = get_crl_delta(ctx, &crl, &dcrl, x);
860.   		/* If error looking up CRL, nothing we can do except
861.   		 * notify callback

crypto/x509/x509_vfy.c:1451:1: start of procedure get_crl_delta()
  1449.    */
  1450.   	
  1451. > static int get_crl_delta(X509_STORE_CTX *ctx,
  1452.   				X509_CRL **pcrl, X509_CRL **pdcrl, X509 *x)
  1453.   	{

crypto/x509/x509_vfy.c:1455:2: 
  1453.   	{
  1454.   	int ok;
  1455. > 	X509 *issuer = NULL;
  1456.   	int crl_score = 0;
  1457.   	unsigned int reasons;

crypto/x509/x509_vfy.c:1456:2: 
  1454.   	int ok;
  1455.   	X509 *issuer = NULL;
  1456. > 	int crl_score = 0;
  1457.   	unsigned int reasons;
  1458.   	X509_CRL *crl = NULL, *dcrl = NULL;

crypto/x509/x509_vfy.c:1458:2: 
  1456.   	int crl_score = 0;
  1457.   	unsigned int reasons;
  1458. > 	X509_CRL *crl = NULL, *dcrl = NULL;
  1459.   	STACK_OF(X509_CRL) *skcrl;
  1460.   	X509_NAME *nm = X509_get_issuer_name(x);

crypto/x509/x509_vfy.c:1460:2: 
  1458.   	X509_CRL *crl = NULL, *dcrl = NULL;
  1459.   	STACK_OF(X509_CRL) *skcrl;
  1460. > 	X509_NAME *nm = X509_get_issuer_name(x);
  1461.   	reasons = ctx->current_reasons;
  1462.   	ok = get_crl_sk(ctx, &crl, &dcrl, 

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

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

static int check_cert(X509_STORE_CTX *ctx)
	{
	X509_CRL *crl = NULL, *dcrl = NULL;
	X509 *x;
	int ok, cnum;
	unsigned int last_reasons;
	cnum = ctx->error_depth;
	x = sk_X509_value(ctx->chain, cnum);
	ctx->current_cert = x;
	ctx->current_issuer = NULL;
	ctx->current_crl_score = 0;
	ctx->current_reasons = 0;
	while (ctx->current_reasons != CRLDP_ALL_REASONS)
		{
		last_reasons = ctx->current_reasons;
		if (ctx->get_crl)
			ok = ctx->get_crl(ctx, &crl, x);
		else
			ok = get_crl_delta(ctx, &crl, &dcrl, x);
		if(!ok)
			{
			ctx->error = X509_V_ERR_UNABLE_TO_GET_CRL;
			ok = ctx->verify_cb(0, ctx);
			goto err;
			}
		ctx->current_crl = crl;
		ok = ctx->check_crl(ctx, crl);
		if (!ok)
			goto err;
		if (dcrl)
			{
			ok = ctx->check_crl(ctx, dcrl);
			if (!ok)
				goto err;
			ok = ctx->cert_crl(ctx, dcrl, x);
			if (!ok)
				goto err;
			}
		else
			ok = 1;
		if (ok != 2)
			{
			ok = ctx->cert_crl(ctx, crl, x);
			if (!ok)
				goto err;
			}
		X509_CRL_free(crl);
		X509_CRL_free(dcrl);
		crl = NULL;
		dcrl = NULL;
		if (last_reasons == ctx->current_reasons)
			{
			ctx->error = X509_V_ERR_UNABLE_TO_GET_CRL;
			ok = ctx->verify_cb(0, ctx);
			goto err;
			}
		}
	err:
	X509_CRL_free(crl);
	X509_CRL_free(dcrl);
	ctx->current_crl = NULL;
	return ok;
	}
['static int check_cert(X509_STORE_CTX *ctx)\n\t{\n\tX509_CRL *crl = NULL, *dcrl = NULL;\n\tX509 *x;\n\tint ok, cnum;\n\tunsigned int last_reasons;\n\tcnum = ctx->error_depth;\n\tx = sk_X509_value(ctx->chain, cnum);\n\tctx->current_cert = x;\n\tctx->current_issuer = NULL;\n\tctx->current_crl_score = 0;\n\tctx->current_reasons = 0;\n\twhile (ctx->current_reasons != CRLDP_ALL_REASONS)\n\t\t{\n\t\tlast_reasons = ctx->current_reasons;\n\t\tif (ctx->get_crl)\n\t\t\tok = ctx->get_crl(ctx, &crl, x);\n\t\telse\n\t\t\tok = get_crl_delta(ctx, &crl, &dcrl, x);\n\t\tif(!ok)\n\t\t\t{\n\t\t\tctx->error = X509_V_ERR_UNABLE_TO_GET_CRL;\n\t\t\tok = ctx->verify_cb(0, ctx);\n\t\t\tgoto err;\n\t\t\t}\n\t\tctx->current_crl = crl;\n\t\tok = ctx->check_crl(ctx, crl);\n\t\tif (!ok)\n\t\t\tgoto err;\n\t\tif (dcrl)\n\t\t\t{\n\t\t\tok = ctx->check_crl(ctx, dcrl);\n\t\t\tif (!ok)\n\t\t\t\tgoto err;\n\t\t\tok = ctx->cert_crl(ctx, dcrl, x);\n\t\t\tif (!ok)\n\t\t\t\tgoto err;\n\t\t\t}\n\t\telse\n\t\t\tok = 1;\n\t\tif (ok != 2)\n\t\t\t{\n\t\t\tok = ctx->cert_crl(ctx, crl, x);\n\t\t\tif (!ok)\n\t\t\t\tgoto err;\n\t\t\t}\n\t\tX509_CRL_free(crl);\n\t\tX509_CRL_free(dcrl);\n\t\tcrl = NULL;\n\t\tdcrl = NULL;\n\t\tif (last_reasons == ctx->current_reasons)\n\t\t\t{\n\t\t\tctx->error = X509_V_ERR_UNABLE_TO_GET_CRL;\n\t\t\tok = ctx->verify_cb(0, ctx);\n\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\terr:\n\tX509_CRL_free(crl);\n\tX509_CRL_free(dcrl);\n\tctx->current_crl = NULL;\n\treturn ok;\n\t}', 'void *sk_value(const _STACK *st, int i)\n{\n\tif(!st || (i < 0) || (i >= st->num)) return NULL;\n\treturn st->data[i];\n}', 'static int get_crl_delta(X509_STORE_CTX *ctx,\n\t\t\t\tX509_CRL **pcrl, X509_CRL **pdcrl, X509 *x)\n\t{\n\tint ok;\n\tX509 *issuer = NULL;\n\tint crl_score = 0;\n\tunsigned int reasons;\n\tX509_CRL *crl = NULL, *dcrl = NULL;\n\tSTACK_OF(X509_CRL) *skcrl;\n\tX509_NAME *nm = X509_get_issuer_name(x);\n\treasons = ctx->current_reasons;\n\tok = get_crl_sk(ctx, &crl, &dcrl,\n\t\t\t\t&issuer, &crl_score, &reasons, ctx->crls);\n\tif (ok)\n\t\tgoto done;\n\tskcrl = ctx->lookup_crls(ctx, nm);\n\tif (!skcrl && crl)\n\t\tgoto done;\n\tget_crl_sk(ctx, &crl, &dcrl, &issuer, &crl_score, &reasons, skcrl);\n\tsk_X509_CRL_pop_free(skcrl, X509_CRL_free);\n\tdone:\n\tif (crl)\n\t\t{\n\t\tctx->current_issuer = issuer;\n\t\tctx->current_crl_score = crl_score;\n\t\tctx->current_reasons = reasons;\n\t\t*pcrl = crl;\n\t\t*pdcrl = dcrl;\n\t\treturn 1;\n\t\t}\n\treturn 0;\n\t}', 'X509_NAME *X509_get_issuer_name(X509 *a)\n\t{\n\treturn(a->cert_info->issuer);\n\t}']