crypto/x509/x509_vfy.c:821: error: NULL_DEREFERENCE
  pointer `xs` last assigned on line 813 could be null and is dereferenced at line 821, column 8.
Showing all 32 steps of the trace


crypto/x509/x509_vfy.c:784:1: start of procedure internal_verify()
782.   	}
783.   
784. > static int internal_verify(X509_STORE_CTX *ctx)
785.   	{
786.   	int ok=0,n;

crypto/x509/x509_vfy.c:786:2: 
784.   static int internal_verify(X509_STORE_CTX *ctx)
785.   	{
786. > 	int ok=0,n;
787.   	X509 *xs,*xi;
788.   	EVP_PKEY *pkey=NULL;

crypto/x509/x509_vfy.c:788:2: 
786.   	int ok=0,n;
787.   	X509 *xs,*xi;
788. > 	EVP_PKEY *pkey=NULL;
789.   	int (*cb)();
790.   

crypto/x509/x509_vfy.c:791:2: 
789.   	int (*cb)();
790.   
791. > 	cb=ctx->verify_cb;
792.   
793.   	n=sk_X509_num(ctx->chain);

crypto/x509/x509_vfy.c:793:2: 
791.   	cb=ctx->verify_cb;
792.   
793. > 	n=sk_X509_num(ctx->chain);
794.   	ctx->error_depth=n-1;
795.   	n--;

crypto/stack/stack.c:302:1: start of procedure sk_num()
  300.   	}
  301.   
  302. > int sk_num(const STACK *st)
  303.   {
  304.   	if(st == NULL) return -1;

crypto/stack/stack.c:304:5: Taking false branch
  302.   int sk_num(const STACK *st)
  303.   {
  304.   	if(st == NULL) return -1;
             ^
  305.   	return st->num;
  306.   }

crypto/stack/stack.c:305:2: 
  303.   {
  304.   	if(st == NULL) return -1;
  305. > 	return st->num;
  306.   }
  307.   

crypto/stack/stack.c:306:1: return from a call to sk_num
  304.   	if(st == NULL) return -1;
  305.   	return st->num;
  306. > }
  307.   
  308.   char *sk_value(const STACK *st, int i)

crypto/x509/x509_vfy.c:794:2: 
792.   
793.   	n=sk_X509_num(ctx->chain);
794. > 	ctx->error_depth=n-1;
795.   	n--;
796.   	xi=sk_X509_value(ctx->chain,n);

crypto/x509/x509_vfy.c:795:2: 
793.   	n=sk_X509_num(ctx->chain);
794.   	ctx->error_depth=n-1;
795. > 	n--;
796.   	xi=sk_X509_value(ctx->chain,n);
797.   

crypto/x509/x509_vfy.c:796:2: 
794.   	ctx->error_depth=n-1;
795.   	n--;
796. > 	xi=sk_X509_value(ctx->chain,n);
797.   
798.   	if (ctx->check_issued(ctx, xi, xi))

crypto/stack/stack.c:308:1: start of procedure sk_value()
  306.   }
  307.   
  308. > char *sk_value(const STACK *st, int i)
  309.   {
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;

crypto/stack/stack.c:310:6: Taking false branch
  308.   char *sk_value(const STACK *st, int i)
  309.   {
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
              ^
  311.   	return st->data[i];
  312.   }

crypto/stack/stack.c:310:13: Taking false branch
  308.   char *sk_value(const STACK *st, int i)
  309.   {
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                     ^
  311.   	return st->data[i];
  312.   }

crypto/stack/stack.c:310:24: Taking false branch
  308.   char *sk_value(const STACK *st, int i)
  309.   {
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                                ^
  311.   	return st->data[i];
  312.   }

crypto/stack/stack.c:311:2: 
  309.   {
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
  311. > 	return st->data[i];
  312.   }
  313.   

crypto/stack/stack.c:312:1: return from a call to sk_value
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
  311.   	return st->data[i];
  312. > }
  313.   
  314.   char *sk_set(STACK *st, int i, char *value)

crypto/x509/x509_vfy.c:798:6: Taking false branch
796.   	xi=sk_X509_value(ctx->chain,n);
797.   
798.   	if (ctx->check_issued(ctx, xi, xi))
            ^
799.   		xs=xi;
800.   	else

crypto/x509/x509_vfy.c:802:7: Taking false branch
800.   	else
801.   		{
802.   		if (n <= 0)
             ^
803.   			{
804.   			ctx->error=X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE;

crypto/x509/x509_vfy.c:811:4: 
809.   		else
810.   			{
811. > 			n--;
812.   			ctx->error_depth=n;
813.   			xs=sk_X509_value(ctx->chain,n);

crypto/x509/x509_vfy.c:812:4: 
810.   			{
811.   			n--;
812. > 			ctx->error_depth=n;
813.   			xs=sk_X509_value(ctx->chain,n);
814.   			}

crypto/x509/x509_vfy.c:813:4: 
811.   			n--;
812.   			ctx->error_depth=n;
813. > 			xs=sk_X509_value(ctx->chain,n);
814.   			}
815.   		}

crypto/stack/stack.c:308:1: start of procedure sk_value()
  306.   }
  307.   
  308. > char *sk_value(const STACK *st, int i)
  309.   {
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;

crypto/stack/stack.c:310:6: Taking false branch
  308.   char *sk_value(const STACK *st, int i)
  309.   {
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
              ^
  311.   	return st->data[i];
  312.   }

crypto/stack/stack.c:310:13: Taking false branch
  308.   char *sk_value(const STACK *st, int i)
  309.   {
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                     ^
  311.   	return st->data[i];
  312.   }

crypto/stack/stack.c:310:24: Taking true branch
  308.   char *sk_value(const STACK *st, int i)
  309.   {
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                                ^
  311.   	return st->data[i];
  312.   }

crypto/stack/stack.c:310:39: 
  308.   char *sk_value(const STACK *st, int i)
  309.   {
  310. > 	if(!st || (i < 0) || (i >= st->num)) return NULL;
  311.   	return st->data[i];
  312.   }

crypto/stack/stack.c:312:1: return from a call to sk_value
  310.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
  311.   	return st->data[i];
  312. > }
  313.   
  314.   char *sk_set(STACK *st, int i, char *value)

crypto/x509/x509_vfy.c:818:9: Loop condition is true. Entering loop body
816.   
817.   /*	ctx->error=0;  not needed */
818.   	while (n >= 0)
               ^
819.   		{
820.   		ctx->error_depth=n;

crypto/x509/x509_vfy.c:820:3: 
818.   	while (n >= 0)
819.   		{
820. > 		ctx->error_depth=n;
821.   		if (!xs->valid)
822.   			{

crypto/x509/x509_vfy.c:821:8: Taking false branch
819.   		{
820.   		ctx->error_depth=n;
821.   		if (!xs->valid)
              ^
822.   			{
823.   			if ((pkey=X509_get_pubkey(xi)) == NULL)

static int internal_verify(X509_STORE_CTX *ctx)
	{
	int ok=0,n;
	X509 *xs,*xi;
	EVP_PKEY *pkey=NULL;
	int (*cb)();
	cb=ctx->verify_cb;
	n=sk_X509_num(ctx->chain);
	ctx->error_depth=n-1;
	n--;
	xi=sk_X509_value(ctx->chain,n);
	if (ctx->check_issued(ctx, xi, xi))
		xs=xi;
	else
		{
		if (n <= 0)
			{
			ctx->error=X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE;
			ctx->current_cert=xi;
			ok=cb(0,ctx);
			goto end;
			}
		else
			{
			n--;
			ctx->error_depth=n;
			xs=sk_X509_value(ctx->chain,n);
			}
		}
	while (n >= 0)
		{
		ctx->error_depth=n;
		if (!xs->valid)
			{
			if ((pkey=X509_get_pubkey(xi)) == NULL)
				{
				ctx->error=X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY;
				ctx->current_cert=xi;
				ok=(*cb)(0,ctx);
				if (!ok) goto end;
				}
			else if (X509_verify(xs,pkey) <= 0)
				{
				ctx->error=X509_V_ERR_CERT_SIGNATURE_FAILURE;
				ctx->current_cert=xs;
				ok=(*cb)(0,ctx);
				if (!ok)
					{
					EVP_PKEY_free(pkey);
					goto end;
					}
				}
			EVP_PKEY_free(pkey);
			pkey=NULL;
			}
		xs->valid = 1;
		if (!check_cert_time(ctx, xs))
			goto end;
		ctx->current_cert=xs;
		ok=(*cb)(1,ctx);
		if (!ok) goto end;
		n--;
		if (n >= 0)
			{
			xi=xs;
			xs=sk_X509_value(ctx->chain,n);
			}
		}
	ok=1;
end:
	return ok;
	}
['static int internal_verify(X509_STORE_CTX *ctx)\n\t{\n\tint ok=0,n;\n\tX509 *xs,*xi;\n\tEVP_PKEY *pkey=NULL;\n\tint (*cb)();\n\tcb=ctx->verify_cb;\n\tn=sk_X509_num(ctx->chain);\n\tctx->error_depth=n-1;\n\tn--;\n\txi=sk_X509_value(ctx->chain,n);\n\tif (ctx->check_issued(ctx, xi, xi))\n\t\txs=xi;\n\telse\n\t\t{\n\t\tif (n <= 0)\n\t\t\t{\n\t\t\tctx->error=X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE;\n\t\t\tctx->current_cert=xi;\n\t\t\tok=cb(0,ctx);\n\t\t\tgoto end;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tn--;\n\t\t\tctx->error_depth=n;\n\t\t\txs=sk_X509_value(ctx->chain,n);\n\t\t\t}\n\t\t}\n\twhile (n >= 0)\n\t\t{\n\t\tctx->error_depth=n;\n\t\tif (!xs->valid)\n\t\t\t{\n\t\t\tif ((pkey=X509_get_pubkey(xi)) == NULL)\n\t\t\t\t{\n\t\t\t\tctx->error=X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY;\n\t\t\t\tctx->current_cert=xi;\n\t\t\t\tok=(*cb)(0,ctx);\n\t\t\t\tif (!ok) goto end;\n\t\t\t\t}\n\t\t\telse if (X509_verify(xs,pkey) <= 0)\n\t\t\t\t{\n\t\t\t\tctx->error=X509_V_ERR_CERT_SIGNATURE_FAILURE;\n\t\t\t\tctx->current_cert=xs;\n\t\t\t\tok=(*cb)(0,ctx);\n\t\t\t\tif (!ok)\n\t\t\t\t\t{\n\t\t\t\t\tEVP_PKEY_free(pkey);\n\t\t\t\t\tgoto end;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tEVP_PKEY_free(pkey);\n\t\t\tpkey=NULL;\n\t\t\t}\n\t\txs->valid = 1;\n\t\tif (!check_cert_time(ctx, xs))\n\t\t\tgoto end;\n\t\tctx->current_cert=xs;\n\t\tok=(*cb)(1,ctx);\n\t\tif (!ok) goto end;\n\t\tn--;\n\t\tif (n >= 0)\n\t\t\t{\n\t\t\txi=xs;\n\t\t\txs=sk_X509_value(ctx->chain,n);\n\t\t\t}\n\t\t}\n\tok=1;\nend:\n\treturn ok;\n\t}', 'int sk_num(const STACK *st)\n{\n\tif(st == NULL) return -1;\n\treturn st->num;\n}', 'char *sk_value(const STACK *st, int i)\n{\n\tif(!st || (i < 0) || (i >= st->num)) return NULL;\n\treturn st->data[i];\n}']