apps/apps.c:2217: error: NULL_DEREFERENCE
  pointer `xptmp` last assigned on line 2216 could be null and is dereferenced by call to `X509_PURPOSE_get_id()` at line 2217, column 15.
Showing all 26 steps of the trace


apps/apps.c:2176:1: start of procedure args_verify()
2174.   }
2175.   
2176. > int args_verify(char ***pargs, int *pargc,
2177.   			int *badarg, BIO *err, X509_VERIFY_PARAM **pm)
2178.   	{

apps/apps.c:2179:2: 
2177.   			int *badarg, BIO *err, X509_VERIFY_PARAM **pm)
2178.   	{
2179. > 	ASN1_OBJECT *otmp = NULL;
2180.   	unsigned long flags = 0;
2181.   	int i;

apps/apps.c:2180:2: 
2178.   	{
2179.   	ASN1_OBJECT *otmp = NULL;
2180. > 	unsigned long flags = 0;
2181.   	int i;
2182.   	int purpose = 0;

apps/apps.c:2182:2: 
2180.   	unsigned long flags = 0;
2181.   	int i;
2182. > 	int purpose = 0;
2183.   	char **oldargs = *pargs;
2184.   	char *arg = **pargs, *argn = (*pargs)[1];

apps/apps.c:2183:2: 
2181.   	int i;
2182.   	int purpose = 0;
2183. > 	char **oldargs = *pargs;
2184.   	char *arg = **pargs, *argn = (*pargs)[1];
2185.   	if (!strcmp(arg, "-policy"))

apps/apps.c:2184:2: 
2182.   	int purpose = 0;
2183.   	char **oldargs = *pargs;
2184. > 	char *arg = **pargs, *argn = (*pargs)[1];
2185.   	if (!strcmp(arg, "-policy"))
2186.   		{

apps/apps.c:2185:7: Taking false branch
2183.   	char **oldargs = *pargs;
2184.   	char *arg = **pargs, *argn = (*pargs)[1];
2185.   	if (!strcmp(arg, "-policy"))
              ^
2186.   		{
2187.   		if (!argn)

apps/apps.c:2201:11: Taking true branch
2199.   		(*pargs)++;
2200.   		}
2201.   	else if (strcmp(arg,"-purpose") == 0)
                  ^
2202.   		{
2203.   		X509_PURPOSE *xptmp;

apps/apps.c:2204:8: Taking false branch
2202.   		{
2203.   		X509_PURPOSE *xptmp;
2204.   		if (!argn)
               ^
2205.   			*badarg = 1;
2206.   		else

apps/apps.c:2208:4: Skipping X509_PURPOSE_get_by_sname(): empty list of specs
2206.   		else
2207.   			{
2208.   			i = X509_PURPOSE_get_by_sname(argn);
           ^
2209.   			if(i < 0)
2210.   				{

apps/apps.c:2209:7: Taking false branch
2207.   			{
2208.   			i = X509_PURPOSE_get_by_sname(argn);
2209.   			if(i < 0)
              ^
2210.   				{
2211.   				BIO_printf(err, "unrecognized purpose\n");

apps/apps.c:2216:5: 
2214.   			else
2215.   				{
2216. > 				xptmp = X509_PURPOSE_get0(i);
2217.   				purpose = X509_PURPOSE_get_id(xptmp);
2218.   				}

crypto/x509v3/v3_purp.c:141:1: start of procedure X509_PURPOSE_get0()
  139.   }
  140.   
  141. > X509_PURPOSE * X509_PURPOSE_get0(int idx)
  142.   {
  143.   	if(idx < 0) return NULL;

crypto/x509v3/v3_purp.c:143:5: Taking false branch
  141.   X509_PURPOSE * X509_PURPOSE_get0(int idx)
  142.   {
  143.   	if(idx < 0) return NULL;
             ^
  144.   	if(idx < (int)X509_PURPOSE_COUNT) return xstandard + idx;
  145.   	return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);

crypto/x509v3/v3_purp.c:144:5: Taking false branch
  142.   {
  143.   	if(idx < 0) return NULL;
  144.   	if(idx < (int)X509_PURPOSE_COUNT) return xstandard + idx;
             ^
  145.   	return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);
  146.   }

crypto/x509v3/v3_purp.c:145:2: 
  143.   	if(idx < 0) return NULL;
  144.   	if(idx < (int)X509_PURPOSE_COUNT) return xstandard + idx;
  145. > 	return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);
  146.   }
  147.   

crypto/x509v3/x509v3.h:478:1: start of procedure sk_X509_PURPOSE_value()
    476.   #define X509V3_ADD_SILENT		0x10
    477.   
    478. > DECLARE_STACK_OF(X509_PURPOSE)
    479.   
    480.   DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)

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

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

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

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

crypto/x509v3/x509v3.h:478:1: return from a call to sk_X509_PURPOSE_value
    476.   #define X509V3_ADD_SILENT		0x10
    477.   
    478. > DECLARE_STACK_OF(X509_PURPOSE)
    479.   
    480.   DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)

crypto/x509v3/v3_purp.c:146:1: return from a call to X509_PURPOSE_get0
  144.   	if(idx < (int)X509_PURPOSE_COUNT) return xstandard + idx;
  145.   	return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);
  146. > }
  147.   
  148.   int X509_PURPOSE_get_by_sname(char *sname)

apps/apps.c:2217:5: 
2215.   				{
2216.   				xptmp = X509_PURPOSE_get0(i);
2217. > 				purpose = X509_PURPOSE_get_id(xptmp);
2218.   				}
2219.   			}

crypto/x509v3/v3_purp.c:250:1: start of procedure X509_PURPOSE_get_id()
  248.   }
  249.   
  250. > int X509_PURPOSE_get_id(X509_PURPOSE *xp)
  251.   {
  252.   	return xp->purpose;

crypto/x509v3/v3_purp.c:252:2: 
  250.   int X509_PURPOSE_get_id(X509_PURPOSE *xp)
  251.   {
  252. > 	return xp->purpose;
  253.   }
  254.   

int args_verify(char ***pargs, int *pargc,
			int *badarg, BIO *err, X509_VERIFY_PARAM **pm)
	{
	ASN1_OBJECT *otmp = NULL;
	unsigned long flags = 0;
	int i;
	int purpose = 0;
	char **oldargs = *pargs;
	char *arg = **pargs, *argn = (*pargs)[1];
	if (!strcmp(arg, "-policy"))
		{
		if (!argn)
			*badarg = 1;
		else
			{
			otmp = OBJ_txt2obj(argn, 0);
			if (!otmp)
				{
				BIO_printf(err, "Invalid Policy \"%s\"\n",
									argn);
				*badarg = 1;
				}
			}
		(*pargs)++;
		}
	else if (strcmp(arg,"-purpose") == 0)
		{
		X509_PURPOSE *xptmp;
		if (!argn)
			*badarg = 1;
		else
			{
			i = X509_PURPOSE_get_by_sname(argn);
			if(i < 0)
				{
				BIO_printf(err, "unrecognized purpose\n");
				*badarg = 1;
				}
			else
				{
				xptmp = X509_PURPOSE_get0(i);
				purpose = X509_PURPOSE_get_id(xptmp);
				}
			}
		(*pargs)++;
		}
	else if (!strcmp(arg, "-ignore_critical"))
		flags |= X509_V_FLAG_IGNORE_CRITICAL;
	else if (!strcmp(arg, "-issuer_checks"))
		flags |= X509_V_FLAG_CB_ISSUER_CHECK;
	else if (!strcmp(arg, "-crl_check"))
		flags |=  X509_V_FLAG_CRL_CHECK;
	else if (!strcmp(arg, "-crl_check_all"))
		flags |= X509_V_FLAG_CRL_CHECK|X509_V_FLAG_CRL_CHECK_ALL;
	else if (!strcmp(arg, "-policy_check"))
		flags |= X509_V_FLAG_POLICY_CHECK;
	else if (!strcmp(arg, "-explicit_policy"))
		flags |= X509_V_FLAG_EXPLICIT_POLICY;
	else if (!strcmp(arg, "-x509_strict"))
		flags |= X509_V_FLAG_X509_STRICT;
	else if (!strcmp(arg, "-policy_print"))
		flags |= X509_V_FLAG_NOTIFY_POLICY;
	else
		return 0;
	if (*badarg)
		{
		if (*pm)
			X509_VERIFY_PARAM_free(*pm);
		*pm = NULL;
		goto end;
		}
	if (!*pm && !(*pm = X509_VERIFY_PARAM_new()))
		{
		*badarg = 1;
		goto end;
		}
	if (otmp)
		X509_VERIFY_PARAM_add0_policy(*pm, otmp);
	if (flags)
		X509_VERIFY_PARAM_set_flags(*pm, flags);
	if (purpose)
		X509_VERIFY_PARAM_set_purpose(*pm, purpose);
	end:
	(*pargs)++;
	if (pargc)
		*pargc -= *pargs - oldargs;
	return 1;
	}
['int args_verify(char ***pargs, int *pargc,\n\t\t\tint *badarg, BIO *err, X509_VERIFY_PARAM **pm)\n\t{\n\tASN1_OBJECT *otmp = NULL;\n\tunsigned long flags = 0;\n\tint i;\n\tint purpose = 0;\n\tchar **oldargs = *pargs;\n\tchar *arg = **pargs, *argn = (*pargs)[1];\n\tif (!strcmp(arg, "-policy"))\n\t\t{\n\t\tif (!argn)\n\t\t\t*badarg = 1;\n\t\telse\n\t\t\t{\n\t\t\totmp = OBJ_txt2obj(argn, 0);\n\t\t\tif (!otmp)\n\t\t\t\t{\n\t\t\t\tBIO_printf(err, "Invalid Policy \\"%s\\"\\n",\n\t\t\t\t\t\t\t\t\targn);\n\t\t\t\t*badarg = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t(*pargs)++;\n\t\t}\n\telse if (strcmp(arg,"-purpose") == 0)\n\t\t{\n\t\tX509_PURPOSE *xptmp;\n\t\tif (!argn)\n\t\t\t*badarg = 1;\n\t\telse\n\t\t\t{\n\t\t\ti = X509_PURPOSE_get_by_sname(argn);\n\t\t\tif(i < 0)\n\t\t\t\t{\n\t\t\t\tBIO_printf(err, "unrecognized purpose\\n");\n\t\t\t\t*badarg = 1;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\txptmp = X509_PURPOSE_get0(i);\n\t\t\t\tpurpose = X509_PURPOSE_get_id(xptmp);\n\t\t\t\t}\n\t\t\t}\n\t\t(*pargs)++;\n\t\t}\n\telse if (!strcmp(arg, "-ignore_critical"))\n\t\tflags |= X509_V_FLAG_IGNORE_CRITICAL;\n\telse if (!strcmp(arg, "-issuer_checks"))\n\t\tflags |= X509_V_FLAG_CB_ISSUER_CHECK;\n\telse if (!strcmp(arg, "-crl_check"))\n\t\tflags |=  X509_V_FLAG_CRL_CHECK;\n\telse if (!strcmp(arg, "-crl_check_all"))\n\t\tflags |= X509_V_FLAG_CRL_CHECK|X509_V_FLAG_CRL_CHECK_ALL;\n\telse if (!strcmp(arg, "-policy_check"))\n\t\tflags |= X509_V_FLAG_POLICY_CHECK;\n\telse if (!strcmp(arg, "-explicit_policy"))\n\t\tflags |= X509_V_FLAG_EXPLICIT_POLICY;\n\telse if (!strcmp(arg, "-x509_strict"))\n\t\tflags |= X509_V_FLAG_X509_STRICT;\n\telse if (!strcmp(arg, "-policy_print"))\n\t\tflags |= X509_V_FLAG_NOTIFY_POLICY;\n\telse\n\t\treturn 0;\n\tif (*badarg)\n\t\t{\n\t\tif (*pm)\n\t\t\tX509_VERIFY_PARAM_free(*pm);\n\t\t*pm = NULL;\n\t\tgoto end;\n\t\t}\n\tif (!*pm && !(*pm = X509_VERIFY_PARAM_new()))\n\t\t{\n\t\t*badarg = 1;\n\t\tgoto end;\n\t\t}\n\tif (otmp)\n\t\tX509_VERIFY_PARAM_add0_policy(*pm, otmp);\n\tif (flags)\n\t\tX509_VERIFY_PARAM_set_flags(*pm, flags);\n\tif (purpose)\n\t\tX509_VERIFY_PARAM_set_purpose(*pm, purpose);\n\tend:\n\t(*pargs)++;\n\tif (pargc)\n\t\t*pargc -= *pargs - oldargs;\n\treturn 1;\n\t}', 'X509_PURPOSE * X509_PURPOSE_get0(int idx)\n{\n\tif(idx < 0) return NULL;\n\tif(idx < (int)X509_PURPOSE_COUNT) return xstandard + idx;\n\treturn sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);\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}', 'int X509_PURPOSE_get_id(X509_PURPOSE *xp)\n{\n\treturn xp->purpose;\n}']