crypto/asn1/a_object.c:239: error: NULL_DEREFERENCE
  pointer `s` last assigned on line 238 could be null and is dereferenced by call to `strncpy()` at line 239, column 3.
Showing all 28 steps of the trace


crypto/asn1/a_object.c:173:1: start of procedure i2t_ASN1_OBJECT()
171.   	}
172.   
173. > int i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a)
174.   	{
175.   	int i,idx=0,n=0,len,nid;

crypto/asn1/a_object.c:175:2: 
173.   int i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a)
174.   	{
175. > 	int i,idx=0,n=0,len,nid;
176.   	unsigned long l;
177.   	unsigned char *p;

crypto/asn1/a_object.c:181:6: Taking false branch
179.   	char tbuf[32];
180.   
181.   	if (buf_len <= 0) return(0);
            ^
182.   
183.   	if ((a == NULL) || (a->data == NULL))

crypto/asn1/a_object.c:183:7: Taking false branch
181.   	if (buf_len <= 0) return(0);
182.   
183.   	if ((a == NULL) || (a->data == NULL))
             ^
184.   		{
185.   		buf[0]='\0';

crypto/asn1/a_object.c:183:22: Taking false branch
181.   	if (buf_len <= 0) return(0);
182.   
183.   	if ((a == NULL) || (a->data == NULL))
                            ^
184.   		{
185.   		buf[0]='\0';

crypto/asn1/a_object.c:189:2: 
187.   		}
188.   
189. > 	nid=OBJ_obj2nid(a);
190.   	if (nid == NID_undef)
191.   		{

crypto/objects/obj_dat.c:354:1: start of procedure OBJ_obj2nid()
  352.   	}
  353.   
  354. > int OBJ_obj2nid(ASN1_OBJECT *a)
  355.   	{
  356.   	ASN1_OBJECT **op;

crypto/objects/obj_dat.c:359:6: Taking false branch
  357.   	ADDED_OBJ ad,*adp;
  358.   
  359.   	if (a == NULL)
              ^
  360.   		return(NID_undef);
  361.   	if (a->nid != 0)

crypto/objects/obj_dat.c:361:6: Taking true branch
  359.   	if (a == NULL)
  360.   		return(NID_undef);
  361.   	if (a->nid != 0)
              ^
  362.   		return(a->nid);
  363.   

crypto/objects/obj_dat.c:362:3: 
  360.   		return(NID_undef);
  361.   	if (a->nid != 0)
  362. > 		return(a->nid);
  363.   
  364.   	if (added != NULL)

crypto/objects/obj_dat.c:376:2: return from a call to OBJ_obj2nid
  374.   		return(NID_undef);
  375.   	return((*op)->nid);
  376.   	}
          ^
  377.   
  378.   /* Convert an object name into an ASN1_OBJECT

crypto/asn1/a_object.c:190:6: Taking false branch
188.   
189.   	nid=OBJ_obj2nid(a);
190.   	if (nid == NID_undef)
            ^
191.   		{
192.   		len=a->length;

crypto/asn1/a_object.c:236:3: 
234.   	else
235.   		{
236. > 		s=OBJ_nid2ln(nid);
237.   		if (s == NULL)
238.   			s=OBJ_nid2sn(nid);

crypto/objects/obj_dat.c:322:1: start of procedure OBJ_nid2ln()
  320.   	}
  321.   
  322. > const char *OBJ_nid2ln(int n)
  323.   	{
  324.   	ADDED_OBJ ad,*adp;

crypto/objects/obj_dat.c:327:7: Taking true branch
  325.   	ASN1_OBJECT ob;
  326.   
  327.   	if ((n >= 0) && (n < NUM_NID))
               ^
  328.   		{
  329.   		if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))

crypto/objects/obj_dat.c:327:19: Taking false branch
  325.   	ASN1_OBJECT ob;
  326.   
  327.   	if ((n >= 0) && (n < NUM_NID))
                           ^
  328.   		{
  329.   		if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))

crypto/objects/obj_dat.c:336:11: Taking true branch
  334.   		return(nid_objs[n].ln);
  335.   		}
  336.   	else if (added == NULL)
                   ^
  337.   		return(NULL);
  338.   	else

crypto/objects/obj_dat.c:337:3: 
  335.   		}
  336.   	else if (added == NULL)
  337. > 		return(NULL);
  338.   	else
  339.   		{

crypto/objects/obj_dat.c:352:2: return from a call to OBJ_nid2ln
  350.   			}
  351.   		}
  352.   	}
          ^
  353.   
  354.   int OBJ_obj2nid(ASN1_OBJECT *a)

crypto/asn1/a_object.c:237:7: Taking true branch
235.   		{
236.   		s=OBJ_nid2ln(nid);
237.   		if (s == NULL)
             ^
238.   			s=OBJ_nid2sn(nid);
239.   		strncpy(buf,s,buf_len);

crypto/asn1/a_object.c:238:4: 
236.   		s=OBJ_nid2ln(nid);
237.   		if (s == NULL)
238. > 			s=OBJ_nid2sn(nid);
239.   		strncpy(buf,s,buf_len);
240.   		n=strlen(s);

crypto/objects/obj_dat.c:290:1: start of procedure OBJ_nid2sn()
  288.   	}
  289.   
  290. > const char *OBJ_nid2sn(int n)
  291.   	{
  292.   	ADDED_OBJ ad,*adp;

crypto/objects/obj_dat.c:295:7: Taking true branch
  293.   	ASN1_OBJECT ob;
  294.   
  295.   	if ((n >= 0) && (n < NUM_NID))
               ^
  296.   		{
  297.   		if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))

crypto/objects/obj_dat.c:295:19: Taking false branch
  293.   	ASN1_OBJECT ob;
  294.   
  295.   	if ((n >= 0) && (n < NUM_NID))
                           ^
  296.   		{
  297.   		if ((n != NID_undef) && (nid_objs[n].nid == NID_undef))

crypto/objects/obj_dat.c:304:11: Taking true branch
  302.   		return(nid_objs[n].sn);
  303.   		}
  304.   	else if (added == NULL)
                   ^
  305.   		return(NULL);
  306.   	else

crypto/objects/obj_dat.c:305:3: 
  303.   		}
  304.   	else if (added == NULL)
  305. > 		return(NULL);
  306.   	else
  307.   		{

crypto/objects/obj_dat.c:320:2: return from a call to OBJ_nid2sn
  318.   			}
  319.   		}
  320.   	}
          ^
  321.   
  322.   const char *OBJ_nid2ln(int n)

crypto/asn1/a_object.c:239:3: 
237.   		if (s == NULL)
238.   			s=OBJ_nid2sn(nid);
239. > 		strncpy(buf,s,buf_len);
240.   		n=strlen(s);
241.   		}

int i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a)
	{
	int i,idx=0,n=0,len,nid;
	unsigned long l;
	unsigned char *p;
	const char *s;
	char tbuf[32];
	if (buf_len <= 0) return(0);
	if ((a == NULL) || (a->data == NULL))
		{
		buf[0]='\0';
		return(0);
		}
	nid=OBJ_obj2nid(a);
	if (nid == NID_undef)
		{
		len=a->length;
		p=a->data;
		idx=0;
		l=0;
		while (idx < a->length)
			{
			l|=(p[idx]&0x7f);
			if (!(p[idx] & 0x80)) break;
			l<<=7L;
			idx++;
			}
		idx++;
		i=(int)(l/40);
		if (i > 2) i=2;
		l-=(long)(i*40);
		sprintf(tbuf,"%d.%ld",i,l);
		i=strlen(tbuf);
		strncpy(buf,tbuf,buf_len);
		buf_len-=i;
		buf+=i;
		n+=i;
		l=0;
		for (; idx<len; idx++)
			{
			l|=p[idx]&0x7f;
			if (!(p[idx] & 0x80))
				{
				sprintf(tbuf,".%ld",l);
				i=strlen(tbuf);
				if (buf_len > 0)
					strncpy(buf,tbuf,buf_len);
				buf_len-=i;
				buf+=i;
				n+=i;
				l=0;
				}
			l<<=7L;
			}
		}
	else
		{
		s=OBJ_nid2ln(nid);
		if (s == NULL)
			s=OBJ_nid2sn(nid);
		strncpy(buf,s,buf_len);
		n=strlen(s);
		}
	buf[buf_len-1]='\0';
	return(n);
	}
['int i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a)\n\t{\n\tint i,idx=0,n=0,len,nid;\n\tunsigned long l;\n\tunsigned char *p;\n\tconst char *s;\n\tchar tbuf[32];\n\tif (buf_len <= 0) return(0);\n\tif ((a == NULL) || (a->data == NULL))\n\t\t{\n\t\tbuf[0]=\'\\0\';\n\t\treturn(0);\n\t\t}\n\tnid=OBJ_obj2nid(a);\n\tif (nid == NID_undef)\n\t\t{\n\t\tlen=a->length;\n\t\tp=a->data;\n\t\tidx=0;\n\t\tl=0;\n\t\twhile (idx < a->length)\n\t\t\t{\n\t\t\tl|=(p[idx]&0x7f);\n\t\t\tif (!(p[idx] & 0x80)) break;\n\t\t\tl<<=7L;\n\t\t\tidx++;\n\t\t\t}\n\t\tidx++;\n\t\ti=(int)(l/40);\n\t\tif (i > 2) i=2;\n\t\tl-=(long)(i*40);\n\t\tsprintf(tbuf,"%d.%ld",i,l);\n\t\ti=strlen(tbuf);\n\t\tstrncpy(buf,tbuf,buf_len);\n\t\tbuf_len-=i;\n\t\tbuf+=i;\n\t\tn+=i;\n\t\tl=0;\n\t\tfor (; idx<len; idx++)\n\t\t\t{\n\t\t\tl|=p[idx]&0x7f;\n\t\t\tif (!(p[idx] & 0x80))\n\t\t\t\t{\n\t\t\t\tsprintf(tbuf,".%ld",l);\n\t\t\t\ti=strlen(tbuf);\n\t\t\t\tif (buf_len > 0)\n\t\t\t\t\tstrncpy(buf,tbuf,buf_len);\n\t\t\t\tbuf_len-=i;\n\t\t\t\tbuf+=i;\n\t\t\t\tn+=i;\n\t\t\t\tl=0;\n\t\t\t\t}\n\t\t\tl<<=7L;\n\t\t\t}\n\t\t}\n\telse\n\t\t{\n\t\ts=OBJ_nid2ln(nid);\n\t\tif (s == NULL)\n\t\t\ts=OBJ_nid2sn(nid);\n\t\tstrncpy(buf,s,buf_len);\n\t\tn=strlen(s);\n\t\t}\n\tbuf[buf_len-1]=\'\\0\';\n\treturn(n);\n\t}', 'int OBJ_obj2nid(ASN1_OBJECT *a)\n\t{\n\tASN1_OBJECT **op;\n\tADDED_OBJ ad,*adp;\n\tif (a == NULL)\n\t\treturn(NID_undef);\n\tif (a->nid != 0)\n\t\treturn(a->nid);\n\tif (added != NULL)\n\t\t{\n\t\tad.type=ADDED_DATA;\n\t\tad.obj=a;\n\t\tadp=(ADDED_OBJ *)lh_retrieve(added,(char *)&ad);\n\t\tif (adp != NULL) return (adp->obj->nid);\n\t\t}\n\top=(ASN1_OBJECT **)OBJ_bsearch((char *)&a,(char *)obj_objs,NUM_OBJ,\n\t\tsizeof(ASN1_OBJECT *),(int (*)())obj_cmp);\n\tif (op == NULL)\n\t\treturn(NID_undef);\n\treturn((*op)->nid);\n\t}', 'const char *OBJ_nid2ln(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_NID2LN,OBJ_R_UNKNOWN_NID);\n\t\t\treturn(NULL);\n\t\t\t}\n\t\treturn(nid_objs[n].ln);\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->ln);\n\t\telse\n\t\t\t{\n\t\t\tOBJerr(OBJ_F_OBJ_NID2LN,OBJ_R_UNKNOWN_NID);\n\t\t\treturn(NULL);\n\t\t\t}\n\t\t}\n\t}', 'const char *OBJ_nid2sn(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_NID2SN,OBJ_R_UNKNOWN_NID);\n\t\t\treturn(NULL);\n\t\t\t}\n\t\treturn(nid_objs[n].sn);\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->sn);\n\t\telse\n\t\t\t{\n\t\t\tOBJerr(OBJ_F_OBJ_NID2SN,OBJ_R_UNKNOWN_NID);\n\t\t\treturn(NULL);\n\t\t\t}\n\t\t}\n\t}']