crypto/x509/x509_vfy.c:243: error: NULL_DEREFERENCE
  pointer `x` last assigned on line 229 could be null and is dereferenced by call to `cert_self_signed()` at line 243, column 7.
Showing all 30 steps of the trace


crypto/x509/x509_vfy.c:189:1: start of procedure X509_verify_cert()
187.   	}
188.   
189. > int X509_verify_cert(X509_STORE_CTX *ctx)
190.   	{
191.   	X509 *x,*xtmp,*chain_ss=NULL;

crypto/x509/x509_vfy.c:191:2: 
189.   int X509_verify_cert(X509_STORE_CTX *ctx)
190.   	{
191. > 	X509 *x,*xtmp,*chain_ss=NULL;
192.   	int bad_chain = 0;
193.   	X509_VERIFY_PARAM *param = ctx->param;

crypto/x509/x509_vfy.c:192:2: 
190.   	{
191.   	X509 *x,*xtmp,*chain_ss=NULL;
192. > 	int bad_chain = 0;
193.   	X509_VERIFY_PARAM *param = ctx->param;
194.   	int depth,i,ok=0;

crypto/x509/x509_vfy.c:193:2: 
191.   	X509 *x,*xtmp,*chain_ss=NULL;
192.   	int bad_chain = 0;
193. > 	X509_VERIFY_PARAM *param = ctx->param;
194.   	int depth,i,ok=0;
195.   	int num;

crypto/x509/x509_vfy.c:194:2: 
192.   	int bad_chain = 0;
193.   	X509_VERIFY_PARAM *param = ctx->param;
194. > 	int depth,i,ok=0;
195.   	int num;
196.   	int (*cb)(int xok,X509_STORE_CTX *xctx);

crypto/x509/x509_vfy.c:197:2: 
195.   	int num;
196.   	int (*cb)(int xok,X509_STORE_CTX *xctx);
197. > 	STACK_OF(X509) *sktmp=NULL;
198.   	if (ctx->cert == NULL)
199.   		{

crypto/x509/x509_vfy.c:198:6: Taking false branch
196.   	int (*cb)(int xok,X509_STORE_CTX *xctx);
197.   	STACK_OF(X509) *sktmp=NULL;
198.   	if (ctx->cert == NULL)
            ^
199.   		{
200.   		X509err(X509_F_X509_VERIFY_CERT,X509_R_NO_CERT_SET_FOR_US_TO_VERIFY);

crypto/x509/x509_vfy.c:204:2: 
202.   		}
203.   
204. > 	cb=ctx->verify_cb;
205.   
206.   	/* first we make sure the chain we are going to build is

crypto/x509/x509_vfy.c:208:6: Taking false branch
206.   	/* first we make sure the chain we are going to build is
207.   	 * present and that the first entry is in place */
208.   	if (ctx->chain == NULL)
            ^
209.   		{
210.   		if (	((ctx->chain=sk_X509_new_null()) == NULL) ||

crypto/x509/x509_vfy.c:221:6: Taking false branch
219.   
220.   	/* We use a temporary STACK so we can chop and hack at it */
221.   	if (ctx->untrusted != NULL
            ^
222.   	    && (sktmp=sk_X509_dup(ctx->untrusted)) == NULL)
223.   		{

crypto/x509/x509_vfy.c:228:6: Condition is true
226.   		}
227.   
228.   	num=sk_X509_num(ctx->chain);
            ^
229.   	x=sk_X509_value(ctx->chain,num-1);
230.   	depth=param->depth;

crypto/x509/x509_vfy.c:228:2: 
226.   		}
227.   
228. > 	num=sk_X509_num(ctx->chain);
229.   	x=sk_X509_value(ctx->chain,num-1);
230.   	depth=param->depth;

crypto/stack/stack.c:294:1: start of procedure sk_num()
  292.   	}
  293.   
  294. > int sk_num(const _STACK *st)
  295.   {
  296.   	if(st == NULL) return -1;

crypto/stack/stack.c:296:5: Taking false branch
  294.   int sk_num(const _STACK *st)
  295.   {
  296.   	if(st == NULL) return -1;
             ^
  297.   	return st->num;
  298.   }

crypto/stack/stack.c:297:2: 
  295.   {
  296.   	if(st == NULL) return -1;
  297. > 	return st->num;
  298.   }
  299.   

crypto/stack/stack.c:298:1: return from a call to sk_num
  296.   	if(st == NULL) return -1;
  297.   	return st->num;
  298. > }
  299.   
  300.   void *sk_value(const _STACK *st, int i)

crypto/x509/x509_vfy.c:229:4: Condition is true
227.   
228.   	num=sk_X509_num(ctx->chain);
229.   	x=sk_X509_value(ctx->chain,num-1);
          ^
230.   	depth=param->depth;
231.   

crypto/x509/x509_vfy.c:229:2: 
227.   
228.   	num=sk_X509_num(ctx->chain);
229. > 	x=sk_X509_value(ctx->chain,num-1);
230.   	depth=param->depth;
231.   

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 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:230:2: 
228.   	num=sk_X509_num(ctx->chain);
229.   	x=sk_X509_value(ctx->chain,num-1);
230. > 	depth=param->depth;
231.   
232.   

crypto/x509/x509_vfy.c:283:3: Loop condition is true. Entering loop body
281.   			}
282.   		break;
283.   		}
         ^
284.   
285.   	/* at this point, chain should contain a list of untrusted

crypto/x509/x509_vfy.c:236:7: Taking false branch
234.   		{
235.   		/* If we have enough, we break */
236.   		if (depth < num) break; /* FIXME: If this happens, we should take
             ^
237.   		                         * note of it and, if appropriate, use the
238.   		                         * X509_V_ERR_CERT_CHAIN_TOO_LONG error

crypto/x509/x509_vfy.c:243:7: 
241.   
242.   		/* If we are self signed, we break */
243. > 		if (cert_self_signed(x))
244.   			break;
245.   		/* If asked see if we can find issuer in trusted store first */

crypto/x509/x509_vfy.c:154:1: start of procedure cert_self_signed()
  152.   #endif
  153.   /* Return 1 is a certificate is self signed */
  154. > static int cert_self_signed(X509 *x)
  155.   	{
  156.   	X509_check_purpose(x, -1, 0);

crypto/x509/x509_vfy.c:156:2: Skipping X509_check_purpose(): empty list of specs
  154.   static int cert_self_signed(X509 *x)
  155.   	{
  156.   	X509_check_purpose(x, -1, 0);
          ^
  157.   	if (x->ex_flags & EXFLAG_SS)
  158.   		return 1;

crypto/x509/x509_vfy.c:157:6: 
  155.   	{
  156.   	X509_check_purpose(x, -1, 0);
  157. > 	if (x->ex_flags & EXFLAG_SS)
  158.   		return 1;
  159.   	else
