crypto/pkcs7/example.c:290: error: NULL_DEREFERENCE
  pointer `so` last assigned on line 289 could be null and is dereferenced at line 290, column 6.
Showing all 49 steps of the trace


crypto/pkcs7/example.c:278:1: start of procedure sk_get_seq2string()
276.   
277.   /* For this case, I will malloc the return strings */
278. > int sk_get_seq2string(STACK_OF(X509_ATTRIBUTE) *sk, char **str1, char **str2)
279.   	{
280.   	ASN1_TYPE *so;

crypto/pkcs7/example.c:283:6: Taking true branch
281.   	PKCS7_SIGNER_INFO si;
282.   
283.   	if (signed_seq2string_nid == -1)
            ^
284.   		signed_seq2string_nid=
285.   			OBJ_create("1.9.9999","OID_example","Our example OID");

crypto/pkcs7/example.c:284:3: 
282.   
283.   	if (signed_seq2string_nid == -1)
284. > 		signed_seq2string_nid=
285.   			OBJ_create("1.9.9999","OID_example","Our example OID");
286.   

crypto/objects/obj_dat.c:628:1: start of procedure OBJ_create()
  626.   	}
  627.   
  628. > int OBJ_create(char *oid, char *sn, char *ln)
  629.   	{
  630.   	int ok=0;

crypto/objects/obj_dat.c:630:2: 
  628.   int OBJ_create(char *oid, char *sn, char *ln)
  629.   	{
  630. > 	int ok=0;
  631.   	ASN1_OBJECT *op=NULL;
  632.   	unsigned char *buf;

crypto/objects/obj_dat.c:631:2: 
  629.   	{
  630.   	int ok=0;
  631. > 	ASN1_OBJECT *op=NULL;
  632.   	unsigned char *buf;
  633.   	int i;

crypto/objects/obj_dat.c:635:2: Skipping a2d_ASN1_OBJECT(): empty list of specs
  633.   	int i;
  634.   
  635.   	i=a2d_ASN1_OBJECT(NULL,0,oid,-1);
          ^
  636.   	if (i <= 0) return(0);
  637.   

crypto/objects/obj_dat.c:636:6: Taking false branch
  634.   
  635.   	i=a2d_ASN1_OBJECT(NULL,0,oid,-1);
  636.   	if (i <= 0) return(0);
              ^
  637.   
  638.   	if ((buf=(unsigned char *)Malloc(i)) == NULL)

crypto/objects/obj_dat.c:638:6: Taking false branch
  636.   	if (i <= 0) return(0);
  637.   
  638.   	if ((buf=(unsigned char *)Malloc(i)) == NULL)
              ^
  639.   		{
  640.   		OBJerr(OBJ_F_OBJ_CREATE,OBJ_R_MALLOC_FAILURE);

crypto/objects/obj_dat.c:643:2: Skipping a2d_ASN1_OBJECT(): empty list of specs
  641.   		return(0);
  642.   		}
  643.   	i=a2d_ASN1_OBJECT(buf,i,oid,-1);
          ^
  644.   	op=(ASN1_OBJECT *)ASN1_OBJECT_create(OBJ_new_nid(1),buf,i,sn,ln);
  645.   	if (op == NULL) 

crypto/objects/obj_dat.c:644:2: 
  642.   		}
  643.   	i=a2d_ASN1_OBJECT(buf,i,oid,-1);
  644. > 	op=(ASN1_OBJECT *)ASN1_OBJECT_create(OBJ_new_nid(1),buf,i,sn,ln);
  645.   	if (op == NULL) 
  646.   		goto err;

crypto/objects/obj_dat.c:205:1: start of procedure OBJ_new_nid()
    203.   	}
    204.   
    205. > int OBJ_new_nid(int num)
    206.   	{
    207.   	int i;

crypto/objects/obj_dat.c:209:2: 
    207.   	int i;
    208.   
    209. > 	i=new_nid;
    210.   	new_nid+=num;
    211.   	return(i);

crypto/objects/obj_dat.c:210:2: 
    208.   
    209.   	i=new_nid;
    210. > 	new_nid+=num;
    211.   	return(i);
    212.   	}

crypto/objects/obj_dat.c:211:2: 
    209.   	i=new_nid;
    210.   	new_nid+=num;
    211. > 	return(i);
    212.   	}
    213.   

crypto/objects/obj_dat.c:212:2: return from a call to OBJ_new_nid
    210.   	new_nid+=num;
    211.   	return(i);
    212.   	}
            ^
    213.   
    214.   int OBJ_add_object(ASN1_OBJECT *obj)

crypto/asn1/a_object.c:288:1: start of procedure ASN1_OBJECT_create()
    286.   	}
    287.   
    288. > ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,
    289.   	     char *sn, char *ln)
    290.   	{

crypto/asn1/a_object.c:293:2: 
    291.   	ASN1_OBJECT o;
    292.   
    293. > 	o.sn=sn;
    294.   	o.ln=ln;
    295.   	o.data=data;

crypto/asn1/a_object.c:294:2: 
    292.   
    293.   	o.sn=sn;
    294. > 	o.ln=ln;
    295.   	o.data=data;
    296.   	o.nid=nid;

crypto/asn1/a_object.c:295:2: 
    293.   	o.sn=sn;
    294.   	o.ln=ln;
    295. > 	o.data=data;
    296.   	o.nid=nid;
    297.   	o.length=len;

crypto/asn1/a_object.c:296:2: 
    294.   	o.ln=ln;
    295.   	o.data=data;
    296. > 	o.nid=nid;
    297.   	o.length=len;
    298.   	o.flags=ASN1_OBJECT_FLAG_DYNAMIC|ASN1_OBJECT_FLAG_DYNAMIC_STRINGS|

crypto/asn1/a_object.c:297:2: 
    295.   	o.data=data;
    296.   	o.nid=nid;
    297. > 	o.length=len;
    298.   	o.flags=ASN1_OBJECT_FLAG_DYNAMIC|ASN1_OBJECT_FLAG_DYNAMIC_STRINGS|
    299.   		ASN1_OBJECT_FLAG_DYNAMIC_DATA;

crypto/asn1/a_object.c:298:2: 
    296.   	o.nid=nid;
    297.   	o.length=len;
    298. > 	o.flags=ASN1_OBJECT_FLAG_DYNAMIC|ASN1_OBJECT_FLAG_DYNAMIC_STRINGS|
    299.   		ASN1_OBJECT_FLAG_DYNAMIC_DATA;
    300.   	return(OBJ_dup(&o));

crypto/asn1/a_object.c:300:2: Skipping OBJ_dup(): empty list of specs
    298.   	o.flags=ASN1_OBJECT_FLAG_DYNAMIC|ASN1_OBJECT_FLAG_DYNAMIC_STRINGS|
    299.   		ASN1_OBJECT_FLAG_DYNAMIC_DATA;
    300.   	return(OBJ_dup(&o));
            ^
    301.   	}
    302.   

crypto/asn1/a_object.c:301:2: return from a call to ASN1_OBJECT_create
    299.   		ASN1_OBJECT_FLAG_DYNAMIC_DATA;
    300.   	return(OBJ_dup(&o));
    301.   	}
            ^
    302.   
    303.   IMPLEMENT_STACK_OF(ASN1_OBJECT)

crypto/objects/obj_dat.c:645:6: Taking false branch
  643.   	i=a2d_ASN1_OBJECT(buf,i,oid,-1);
  644.   	op=(ASN1_OBJECT *)ASN1_OBJECT_create(OBJ_new_nid(1),buf,i,sn,ln);
  645.   	if (op == NULL) 
              ^
  646.   		goto err;
  647.   	ok=OBJ_add_object(op);

crypto/objects/obj_dat.c:647:2: Skipping OBJ_add_object(): empty list of specs
  645.   	if (op == NULL) 
  646.   		goto err;
  647.   	ok=OBJ_add_object(op);
          ^
  648.   err:
  649.   	ASN1_OBJECT_free(op);

crypto/objects/obj_dat.c:648:1: 
  646.   		goto err;
  647.   	ok=OBJ_add_object(op);
  648. > err:
  649.   	ASN1_OBJECT_free(op);
  650.   	Free((char *)buf);

crypto/objects/obj_dat.c:649:2: Skipping ASN1_OBJECT_free(): empty list of specs
  647.   	ok=OBJ_add_object(op);
  648.   err:
  649.   	ASN1_OBJECT_free(op);
          ^
  650.   	Free((char *)buf);
  651.   	return(ok);

crypto/objects/obj_dat.c:650:2: 
  648.   err:
  649.   	ASN1_OBJECT_free(op);
  650. > 	Free((char *)buf);
  651.   	return(ok);
  652.   	}

crypto/objects/obj_dat.c:651:2: 
  649.   	ASN1_OBJECT_free(op);
  650.   	Free((char *)buf);
  651. > 	return(ok);
  652.   	}
  653.   

crypto/objects/obj_dat.c:652:2: return from a call to OBJ_create
  650.   	Free((char *)buf);
  651.   	return(ok);
  652.   	}
          ^
  653.   

crypto/pkcs7/example.c:287:2: 
285.   			OBJ_create("1.9.9999","OID_example","Our example OID");
286.   
287. > 	si.auth_attr=sk;
288.   	/* To retrieve */
289.   	so=PKCS7_get_signed_attribute(&si,signed_seq2string_nid);

crypto/pkcs7/example.c:289:2: 
287.   	si.auth_attr=sk;
288.   	/* To retrieve */
289. > 	so=PKCS7_get_signed_attribute(&si,signed_seq2string_nid);
290.   	if (so->type == V_ASN1_SEQUENCE)
291.   		{

crypto/pkcs7/pk7_doit.c:824:1: start of procedure PKCS7_get_signed_attribute()
  822.   	}
  823.   
  824. > ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid)
  825.   	{
  826.   	return(get_attribute(si->auth_attr,nid));

crypto/pkcs7/pk7_doit.c:826:2: 
  824.   ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid)
  825.   	{
  826. > 	return(get_attribute(si->auth_attr,nid));
  827.   	}
  828.   

crypto/pkcs7/pk7_doit.c:834:1: start of procedure get_attribute()
    832.   	}
    833.   
    834. > static ASN1_TYPE *get_attribute(STACK_OF(X509_ATTRIBUTE) *sk, int nid)
    835.   	{
    836.   	int i;

crypto/pkcs7/pk7_doit.c:840:2: 
    838.   	ASN1_OBJECT *o;
    839.   
    840. > 	o=OBJ_nid2obj(nid);
    841.   	if (!o || !sk) return(NULL);
    842.   	for (i=0; i<sk_X509_ATTRIBUTE_num(sk); i++)

crypto/objects/obj_dat.c:258:1: start of procedure OBJ_nid2obj()
      256.   	}
      257.   
      258. > ASN1_OBJECT *OBJ_nid2obj(int n)
      259.   	{
      260.   	ADDED_OBJ ad,*adp;

crypto/objects/obj_dat.c:263:7: Taking true branch
      261.   	ASN1_OBJECT ob;
      262.   
      263.   	if ((n >= 0) && (n < NUM_NID))
                   ^
      264.   		{
      265.   		if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))

crypto/objects/obj_dat.c:263:19: Taking false branch
      261.   	ASN1_OBJECT ob;
      262.   
      263.   	if ((n >= 0) && (n < NUM_NID))
                               ^
      264.   		{
      265.   		if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))

crypto/objects/obj_dat.c:272:11: Taking true branch
      270.   		return((ASN1_OBJECT *)&(nid_objs[n]));
      271.   		}
      272.   	else if (added == NULL)
                       ^
      273.   		return(NULL);
      274.   	else

crypto/objects/obj_dat.c:273:3: 
      271.   		}
      272.   	else if (added == NULL)
      273. > 		return(NULL);
      274.   	else
      275.   		{

crypto/objects/obj_dat.c:288:2: return from a call to OBJ_nid2obj
      286.   			}
      287.   		}
      288.   	}
              ^
      289.   
      290.   const char *OBJ_nid2sn(int n)

crypto/pkcs7/pk7_doit.c:841:7: Taking true branch
    839.   
    840.   	o=OBJ_nid2obj(nid);
    841.   	if (!o || !sk) return(NULL);
                 ^
    842.   	for (i=0; i<sk_X509_ATTRIBUTE_num(sk); i++)
    843.   		{

crypto/pkcs7/pk7_doit.c:841:17: 
    839.   
    840.   	o=OBJ_nid2obj(nid);
    841. > 	if (!o || !sk) return(NULL);
    842.   	for (i=0; i<sk_X509_ATTRIBUTE_num(sk); i++)
    843.   		{

crypto/pkcs7/pk7_doit.c:854:2: return from a call to get_attribute
    852.   		}
    853.   	return(NULL);
    854.   	}
            ^
    855.   
    856.   ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk)

crypto/pkcs7/pk7_doit.c:827:2: return from a call to PKCS7_get_signed_attribute
  825.   	{
  826.   	return(get_attribute(si->auth_attr,nid));
  827.   	}
          ^
  828.   
  829.   ASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid)

crypto/pkcs7/example.c:290:6: 
288.   	/* To retrieve */
289.   	so=PKCS7_get_signed_attribute(&si,signed_seq2string_nid);
290. > 	if (so->type == V_ASN1_SEQUENCE)
291.   		{
292.   		ASN1_CTX c;

int sk_get_seq2string(STACK_OF(X509_ATTRIBUTE) *sk, char **str1, char **str2)
	{
	ASN1_TYPE *so;
	PKCS7_SIGNER_INFO si;
	if (signed_seq2string_nid == -1)
		signed_seq2string_nid=
			OBJ_create("1.9.9999","OID_example","Our example OID");
	si.auth_attr=sk;
	so=PKCS7_get_signed_attribute(&si,signed_seq2string_nid);
	if (so->type == V_ASN1_SEQUENCE)
		{
		ASN1_CTX c;
		ASN1_STRING *s;
		long length;
		ASN1_OCTET_STRING *os1,*os2;
		s=so->value.sequence;
		c.p=ASN1_STRING_data(s);
		c.max=c.p+ASN1_STRING_length(s);
		if (!asn1_GetSequence(&c,&length)) goto err;
		c.q=c.p;
		if ((os1=d2i_ASN1_OCTET_STRING(NULL,&c.p,c.slen)) == NULL)
			goto err;
		c.slen-=(c.p-c.q);
		c.q=c.p;
		if ((os2=d2i_ASN1_OCTET_STRING(NULL,&c.p,c.slen)) == NULL)
			goto err;
		c.slen-=(c.p-c.q);
		if (!asn1_Finish(&c)) goto err;
		*str1=malloc(os1->length+1);
		*str2=malloc(os2->length+1);
		memcpy(*str1,os1->data,os1->length);
		memcpy(*str2,os2->data,os2->length);
		(*str1)[os1->length]='\0';
		(*str2)[os2->length]='\0';
		ASN1_OCTET_STRING_free(os1);
		ASN1_OCTET_STRING_free(os2);
		return(1);
		}
err:
	return(0);
	}
['int sk_get_seq2string(STACK_OF(X509_ATTRIBUTE) *sk, char **str1, char **str2)\n\t{\n\tASN1_TYPE *so;\n\tPKCS7_SIGNER_INFO si;\n\tif (signed_seq2string_nid == -1)\n\t\tsigned_seq2string_nid=\n\t\t\tOBJ_create("1.9.9999","OID_example","Our example OID");\n\tsi.auth_attr=sk;\n\tso=PKCS7_get_signed_attribute(&si,signed_seq2string_nid);\n\tif (so->type == V_ASN1_SEQUENCE)\n\t\t{\n\t\tASN1_CTX c;\n\t\tASN1_STRING *s;\n\t\tlong length;\n\t\tASN1_OCTET_STRING *os1,*os2;\n\t\ts=so->value.sequence;\n\t\tc.p=ASN1_STRING_data(s);\n\t\tc.max=c.p+ASN1_STRING_length(s);\n\t\tif (!asn1_GetSequence(&c,&length)) goto err;\n\t\tc.q=c.p;\n\t\tif ((os1=d2i_ASN1_OCTET_STRING(NULL,&c.p,c.slen)) == NULL)\n\t\t\tgoto err;\n\t\tc.slen-=(c.p-c.q);\n\t\tc.q=c.p;\n\t\tif ((os2=d2i_ASN1_OCTET_STRING(NULL,&c.p,c.slen)) == NULL)\n\t\t\tgoto err;\n\t\tc.slen-=(c.p-c.q);\n\t\tif (!asn1_Finish(&c)) goto err;\n\t\t*str1=malloc(os1->length+1);\n\t\t*str2=malloc(os2->length+1);\n\t\tmemcpy(*str1,os1->data,os1->length);\n\t\tmemcpy(*str2,os2->data,os2->length);\n\t\t(*str1)[os1->length]=\'\\0\';\n\t\t(*str2)[os2->length]=\'\\0\';\n\t\tASN1_OCTET_STRING_free(os1);\n\t\tASN1_OCTET_STRING_free(os2);\n\t\treturn(1);\n\t\t}\nerr:\n\treturn(0);\n\t}', 'int OBJ_create(char *oid, char *sn, char *ln)\n\t{\n\tint ok=0;\n\tASN1_OBJECT *op=NULL;\n\tunsigned char *buf;\n\tint i;\n\ti=a2d_ASN1_OBJECT(NULL,0,oid,-1);\n\tif (i <= 0) return(0);\n\tif ((buf=(unsigned char *)Malloc(i)) == NULL)\n\t\t{\n\t\tOBJerr(OBJ_F_OBJ_CREATE,OBJ_R_MALLOC_FAILURE);\n\t\treturn(0);\n\t\t}\n\ti=a2d_ASN1_OBJECT(buf,i,oid,-1);\n\top=(ASN1_OBJECT *)ASN1_OBJECT_create(OBJ_new_nid(1),buf,i,sn,ln);\n\tif (op == NULL)\n\t\tgoto err;\n\tok=OBJ_add_object(op);\nerr:\n\tASN1_OBJECT_free(op);\n\tFree((char *)buf);\n\treturn(ok);\n\t}', 'int OBJ_new_nid(int num)\n\t{\n\tint i;\n\ti=new_nid;\n\tnew_nid+=num;\n\treturn(i);\n\t}', 'ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,\n\t     char *sn, char *ln)\n\t{\n\tASN1_OBJECT o;\n\to.sn=sn;\n\to.ln=ln;\n\to.data=data;\n\to.nid=nid;\n\to.length=len;\n\to.flags=ASN1_OBJECT_FLAG_DYNAMIC|ASN1_OBJECT_FLAG_DYNAMIC_STRINGS|\n\t\tASN1_OBJECT_FLAG_DYNAMIC_DATA;\n\treturn(OBJ_dup(&o));\n\t}', 'ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid)\n\t{\n\treturn(get_attribute(si->auth_attr,nid));\n\t}', 'static ASN1_TYPE *get_attribute(STACK_OF(X509_ATTRIBUTE) *sk, int nid)\n\t{\n\tint i;\n\tX509_ATTRIBUTE *xa;\n\tASN1_OBJECT *o;\n\to=OBJ_nid2obj(nid);\n\tif (!o || !sk) return(NULL);\n\tfor (i=0; i<sk_X509_ATTRIBUTE_num(sk); i++)\n\t\t{\n\t\txa=sk_X509_ATTRIBUTE_value(sk,i);\n\t\tif (OBJ_cmp(xa->object,o) == 0)\n\t\t\t{\n\t\t\tif (xa->set && sk_ASN1_TYPE_num(xa->value.set))\n\t\t\t\treturn(sk_ASN1_TYPE_value(xa->value.set,0));\n\t\t\telse\n\t\t\t\treturn(NULL);\n\t\t\t}\n\t\t}\n\treturn(NULL);\n\t}', 'ASN1_OBJECT *OBJ_nid2obj(int n)\n\t{\n\tADDED_OBJ ad,*adp;\n\tASN1_OBJECT ob;\n\tif ((n >= 0) && (n < NUM_NID))\n\t\t{\n\t\tif ((n != NID_undef) && (nid_objs[n].nid == NID_undef))\n\t\t\t{\n\t\t\tOBJerr(OBJ_F_OBJ_NID2OBJ,OBJ_R_UNKNOWN_NID);\n\t\t\treturn(NULL);\n\t\t\t}\n\t\treturn((ASN1_OBJECT *)&(nid_objs[n]));\n\t\t}\n\telse if (added == NULL)\n\t\treturn(NULL);\n\telse\n\t\t{\n\t\tad.type=ADDED_NID;\n\t\tad.obj= &ob;\n\t\tob.nid=n;\n\t\tadp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad);\n\t\tif (adp != NULL)\n\t\t\treturn(adp->obj);\n\t\telse\n\t\t\t{\n\t\t\tOBJerr(OBJ_F_OBJ_NID2OBJ,OBJ_R_UNKNOWN_NID);\n\t\t\treturn(NULL);\n\t\t\t}\n\t\t}\n\t}']