crypto/pkcs12/p12_npas.c:122: error: BUFFER_OVERRUN_L3
  Offset: [1, +oo] (⇐ [0, +oo] + 1) Size: [0, +oo] by call to `alg_get`.
Showing all 27 steps of the trace


crypto/pkcs12/p12_npas.c:136:16: Call
134.   		/* Repack bag in same form with new password */
135.   		if (bagnid == NID_pkcs7_data) p7new = PKCS12_pack_p7data(bags);
136.   		else p7new = PKCS12_pack_p7encdata(pbe_nid, newpass, -1, NULL,
                      ^
137.   						 pbe_saltlen, pbe_iter, bags);
138.   		sk_pop_free(bags, PKCS12_SAFEBAG_free);

crypto/pkcs12/p12_add.c:171:2: Call
  169.   	X509_ALGOR_free(p7->d.encrypted->enc_data->algorithm);
  170.   	p7->d.encrypted->enc_data->algorithm = pbe;
  171.   	M_ASN1_OCTET_STRING_free(p7->d.encrypted->enc_data->enc_data);
          ^
  172.   	if (!(p7->d.encrypted->enc_data->enc_data =
  173.   	PKCS12_i2d_encrypt (pbe, i2d_PKCS12_SAFEBAG, pass, passlen,

crypto/asn1/asn1_lib.c:381:1: Parameter `*a->data`
    379.   	}
    380.   
    381. > void ASN1_STRING_free(ASN1_STRING *a)
    382.   	{
    383.   	if (a == NULL) return;

crypto/pkcs12/p12_npas.c:122:4: Call
120.   		} else if (bagnid == NID_pkcs7_encrypted) {
121.   			bags = M_PKCS12_unpack_p7encdata(p7, oldpass, -1);
122.   			alg_get(p7->d.encrypted->enc_data->algorithm,
          ^
123.   				&pbe_nid, &pbe_iter, &pbe_saltlen);
124.   		} else continue;

crypto/pkcs12/p12_npas.c:201:1: Parameter `*alg->parameter->value.sequence->data`
  199.   }
  200.   
  201. > static int alg_get(X509_ALGOR *alg, int *pnid, int *piter, int *psaltlen)
  202.   {
  203.           PBEPARAM *pbe;

crypto/pkcs12/p12_npas.c:205:9: Assignment
  203.           PBEPARAM *pbe;
  204.           unsigned char *p;
  205.           p = alg->parameter->value.sequence->data;
                 ^
  206.           pbe = d2i_PBEPARAM(NULL, &p, alg->parameter->value.sequence->length);
  207.           *pnid = OBJ_obj2nid(alg->algorithm);

crypto/pkcs12/p12_npas.c:206:15: Call
  204.           unsigned char *p;
  205.           p = alg->parameter->value.sequence->data;
  206.           pbe = d2i_PBEPARAM(NULL, &p, alg->parameter->value.sequence->length);
                       ^
  207.           *pnid = OBJ_obj2nid(alg->algorithm);
  208.   	*piter = ASN1_INTEGER_get(pbe->iter);

crypto/asn1/p5_pbe.c:91:1: Parameter `**pp`
    89.   }
    90.   
    91. > PBEPARAM *d2i_PBEPARAM(PBEPARAM **a, unsigned char **pp, long length)
    92.   {
    93.   	M_ASN1_D2I_vars(a,PBEPARAM *,PBEPARAM_new);

crypto/asn1/p5_pbe.c:94:2: Assignment
    92.   {
    93.   	M_ASN1_D2I_vars(a,PBEPARAM *,PBEPARAM_new);
    94.   	M_ASN1_D2I_Init();
           ^
    95.   	M_ASN1_D2I_start_sequence();
    96.   	M_ASN1_D2I_get (ret->salt, d2i_ASN1_OCTET_STRING);

crypto/asn1/p5_pbe.c:95:2: Call
    93.   	M_ASN1_D2I_vars(a,PBEPARAM *,PBEPARAM_new);
    94.   	M_ASN1_D2I_Init();
    95.   	M_ASN1_D2I_start_sequence();
           ^
    96.   	M_ASN1_D2I_get (ret->salt, d2i_ASN1_OCTET_STRING);
    97.   	M_ASN1_D2I_get (ret->iter, d2i_ASN1_INTEGER);

crypto/asn1/asn1_lib.c:277:1: Parameter `*c->p`
      275.   	}
      276.   
      277. > int asn1_GetSequence(ASN1_CTX *c, long *length)
      278.   	{
      279.   	unsigned char *q;

crypto/asn1/asn1_lib.c:282:9: Call
      280.   
      281.   	q=c->p;
      282.   	c->inf=ASN1_get_object(&(c->p),&(c->slen),&(c->tag),&(c->xclass),
                     ^
      283.   		*length);
      284.   	if (c->inf & 0x80)

crypto/asn1/asn1_lib.c:83:1: Parameter `**pp`
        81.   
        82.   
        83. > int ASN1_get_object(unsigned char **pp, long *plength, int *ptag, int *pclass,
        84.   	     long omax)
        85.   	{

crypto/asn1/p5_pbe.c:96:2: Call
    94.   	M_ASN1_D2I_Init();
    95.   	M_ASN1_D2I_start_sequence();
    96.   	M_ASN1_D2I_get (ret->salt, d2i_ASN1_OCTET_STRING);
           ^
    97.   	M_ASN1_D2I_get (ret->iter, d2i_ASN1_INTEGER);
    98.   	M_ASN1_D2I_Finish(a, PBEPARAM_free, ASN1_F_D2I_PBEPARAM);

crypto/asn1/a_octet.c:81:1: Parameter `**pp`
      79.   { return M_i2d_ASN1_OCTET_STRING(a, pp); }
      80.   
      81. > ASN1_OCTET_STRING *d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **a,
      82.   	     unsigned char **pp, long length)
      83.   	{

crypto/asn1/a_octet.c:86:27: Call
      84.   	ASN1_OCTET_STRING *ret=NULL;
      85.   
      86.   	ret=(ASN1_OCTET_STRING *)d2i_ASN1_bytes((ASN1_STRING **)a,
                                      ^
      87.   		pp,length,V_ASN1_OCTET_STRING,V_ASN1_UNIVERSAL);
      88.   	if (ret == NULL)

crypto/asn1/a_bytes.c:167:1: Parameter `**pp`
        165.   	}
        166.   
        167. > ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,
        168.   	     int Ptag, int Pclass)
        169.   	{

crypto/asn1/a_bytes.c:183:2: Assignment
        181.   		ret=(*a);
        182.   
        183.   	p= *pp;
                ^
        184.   	inf=ASN1_get_object(&p,&len,&tag,&xclass,length);
        185.   	if (inf & 0x80)

crypto/asn1/a_bytes.c:184:6: Call
        182.   
        183.   	p= *pp;
        184.   	inf=ASN1_get_object(&p,&len,&tag,&xclass,length);
                    ^
        185.   	if (inf & 0x80)
        186.   		{

crypto/asn1/asn1_lib.c:83:1: Parameter `**pp`
          81.   
          82.   
          83. > int ASN1_get_object(unsigned char **pp, long *plength, int *ptag, int *pclass,
          84.   	     long omax)
          85.   	{

crypto/asn1/a_bytes.c:202:3: Assignment
        200.   
        201.   		c.pp=pp;
        202.   		c.p=p;
                 ^
        203.   		c.inf=inf;
        204.   		c.slen=len;

crypto/asn1/a_bytes.c:208:8: Call
        206.   		c.xclass=Pclass;
        207.   		c.max=(length == 0)?0:(p+length);
        208.   		if (!asn1_collate_primative(ret,&c)) 
                      ^
        209.   			goto err; 
        210.   		else

crypto/asn1/a_bytes.c:261:1: Parameter `*c->p`
          259.   /* There have been a few bug fixes for this function from
          260.    * Paul Keogh <paul.keogh@sse.ie>, many thanks to him */
          261. > static int asn1_collate_primative(ASN1_STRING *a, ASN1_CTX *c)
          262.   	{
          263.   	ASN1_STRING *os=NULL;

crypto/asn1/a_bytes.c:282:11: Call
          280.   		if (c->inf & 1)
          281.   			{
          282.   			c->eos=ASN1_check_infinite_end(&c->p,
                           ^
          283.   				(long)(c->max-c->p));
          284.   			if (c->eos) break;

crypto/asn1/asn1_lib.c:68:1: <Length trace>
66.   const char *ASN1_version="ASN.1" OPENSSL_VERSION_PTEXT;
67.   
68. > int ASN1_check_infinite_end(unsigned char **p, long len)
69.   	{
70.   	/* If there is 0 or 1 byte left, the length check should pick

crypto/asn1/asn1_lib.c:68:1: Parameter `**p`
            66.   const char *ASN1_version="ASN.1" OPENSSL_VERSION_PTEXT;
            67.   
            68. > int ASN1_check_infinite_end(unsigned char **p, long len)
            69.   	{
            70.   	/* If there is 0 or 1 byte left, the length check should pick

crypto/asn1/asn1_lib.c:74:44: Array access: Offset: [1, +oo] (⇐ [0, +oo] + 1) Size: [0, +oo] by call to `alg_get` 
            72.   	if (len <= 0)
            73.   		return(1);
            74.   	else if ((len >= 2) && ((*p)[0] == 0) && ((*p)[1] == 0))
                                                             ^
            75.   		{
            76.   		(*p)+=2;

int ASN1_check_infinite_end(unsigned char **p, long len)
	{
	if (len <= 0)
		return(1);
	else if ((len >= 2) && ((*p)[0] == 0) && ((*p)[1] == 0))
		{
		(*p)+=2;
		return(1);
		}
	return(0);
	}
['static int newpass_p12(PKCS12 *p12, char *oldpass, char *newpass)\n{\n\tSTACK *asafes, *newsafes, *bags;\n\tint i, bagnid, pbe_nid, pbe_iter, pbe_saltlen;\n\tPKCS7 *p7, *p7new;\n\tASN1_OCTET_STRING *p12_data_tmp = NULL, *macnew = NULL;\n\tunsigned char mac[EVP_MAX_MD_SIZE];\n\tunsigned int maclen;\n\tif (!(asafes = M_PKCS12_unpack_authsafes(p12))) return 0;\n\tif(!(newsafes = sk_new(NULL))) return 0;\n\tfor (i = 0; i < sk_num (asafes); i++) {\n\t\tp7 = (PKCS7 *) sk_value(asafes, i);\n\t\tbagnid = OBJ_obj2nid(p7->type);\n\t\tif (bagnid == NID_pkcs7_data) {\n\t\t\tbags = M_PKCS12_unpack_p7data(p7);\n\t\t} else if (bagnid == NID_pkcs7_encrypted) {\n\t\t\tbags = M_PKCS12_unpack_p7encdata(p7, oldpass, -1);\n\t\t\talg_get(p7->d.encrypted->enc_data->algorithm,\n\t\t\t\t&pbe_nid, &pbe_iter, &pbe_saltlen);\n\t\t} else continue;\n\t\tif (!bags) {\n\t\t\tsk_pop_free(asafes, PKCS7_free);\n\t\t\treturn 0;\n\t\t}\n\t    \tif (!newpass_bags(bags, oldpass, newpass)) {\n\t\t\tsk_pop_free(bags, PKCS12_SAFEBAG_free);\n\t\t\tsk_pop_free(asafes, PKCS7_free);\n\t\t\treturn 0;\n\t\t}\n\t\tif (bagnid == NID_pkcs7_data) p7new = PKCS12_pack_p7data(bags);\n\t\telse p7new = PKCS12_pack_p7encdata(pbe_nid, newpass, -1, NULL,\n\t\t\t\t\t\t pbe_saltlen, pbe_iter, bags);\n\t\tsk_pop_free(bags, PKCS12_SAFEBAG_free);\n\t\tif(!p7new) {\n\t\t\tsk_pop_free(asafes, PKCS7_free);\n\t\t\treturn 0;\n\t\t}\n\t\tsk_push(newsafes, (char *)p7new);\n\t}\n\tsk_pop_free(asafes, PKCS7_free);\n\tp12_data_tmp = p12->authsafes->d.data;\n\tif(!(p12->authsafes->d.data = ASN1_OCTET_STRING_new())) goto saferr;\n\tif(!M_PKCS12_pack_authsafes(p12, newsafes)) goto saferr;\n\tif(!PKCS12_gen_mac(p12, newpass, -1, mac, &maclen)) goto saferr;\n\tif(!(macnew = ASN1_OCTET_STRING_new())) goto saferr;\n\tif(!ASN1_OCTET_STRING_set(macnew, mac, maclen)) goto saferr;\n\tASN1_OCTET_STRING_free(p12->mac->dinfo->digest);\n\tp12->mac->dinfo->digest = macnew;\n\tASN1_OCTET_STRING_free(p12_data_tmp);\n\treturn 1;\n\tsaferr:\n\tASN1_OCTET_STRING_free(p12->authsafes->d.data);\n\tASN1_OCTET_STRING_free(macnew);\n\tp12->authsafes->d.data = p12_data_tmp;\n\treturn 0;\n}', 'PKCS7 *PKCS12_pack_p7encdata (int pbe_nid, const char *pass, int passlen,\n\t     unsigned char *salt, int saltlen, int iter, STACK *bags)\n{\n\tPKCS7 *p7;\n\tX509_ALGOR *pbe;\n\tif (!(p7 = PKCS7_new())) {\n\t\tPKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE);\n\t\treturn NULL;\n\t}\n\tif(!PKCS7_set_type(p7, NID_pkcs7_encrypted)) {\n\t\tPKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA,\n\t\t\t\tPKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE);\n\t\treturn NULL;\n\t}\n\tif (!(pbe = PKCS5_pbe_set (pbe_nid, iter, salt, saltlen))) {\n\t\tPKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE);\n\t\treturn NULL;\n\t}\n\tX509_ALGOR_free(p7->d.encrypted->enc_data->algorithm);\n\tp7->d.encrypted->enc_data->algorithm = pbe;\n\tM_ASN1_OCTET_STRING_free(p7->d.encrypted->enc_data->enc_data);\n\tif (!(p7->d.encrypted->enc_data->enc_data =\n\tPKCS12_i2d_encrypt (pbe, i2d_PKCS12_SAFEBAG, pass, passlen,\n\t\t\t\t (char *)bags, 1))) {\n\t\tPKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, PKCS12_R_ENCRYPT_ERROR);\n\t\treturn NULL;\n\t}\n\treturn p7;\n}', 'void ASN1_STRING_free(ASN1_STRING *a)\n\t{\n\tif (a == NULL) return;\n\tif (a->data != NULL) Free((char *)a->data);\n\tFree((char *)a);\n\t}', 'static int alg_get(X509_ALGOR *alg, int *pnid, int *piter, int *psaltlen)\n{\n        PBEPARAM *pbe;\n        unsigned char *p;\n        p = alg->parameter->value.sequence->data;\n        pbe = d2i_PBEPARAM(NULL, &p, alg->parameter->value.sequence->length);\n        *pnid = OBJ_obj2nid(alg->algorithm);\n\t*piter = ASN1_INTEGER_get(pbe->iter);\n\t*psaltlen = pbe->salt->length;\n        PBEPARAM_free(pbe);\n        return 0;\n}', 'PBEPARAM *d2i_PBEPARAM(PBEPARAM **a, unsigned char **pp, long length)\n{\n\tM_ASN1_D2I_vars(a,PBEPARAM *,PBEPARAM_new);\n\tM_ASN1_D2I_Init();\n\tM_ASN1_D2I_start_sequence();\n\tM_ASN1_D2I_get (ret->salt, d2i_ASN1_OCTET_STRING);\n\tM_ASN1_D2I_get (ret->iter, d2i_ASN1_INTEGER);\n\tM_ASN1_D2I_Finish(a, PBEPARAM_free, ASN1_F_D2I_PBEPARAM);\n}', 'int asn1_GetSequence(ASN1_CTX *c, long *length)\n\t{\n\tunsigned char *q;\n\tq=c->p;\n\tc->inf=ASN1_get_object(&(c->p),&(c->slen),&(c->tag),&(c->xclass),\n\t\t*length);\n\tif (c->inf & 0x80)\n\t\t{\n\t\tc->error=ERR_R_BAD_GET_ASN1_OBJECT_CALL;\n\t\treturn(0);\n\t\t}\n\tif (c->tag != V_ASN1_SEQUENCE)\n\t\t{\n\t\tc->error=ERR_R_EXPECTING_AN_ASN1_SEQUENCE;\n\t\treturn(0);\n\t\t}\n\t(*length)-=(c->p-q);\n\tif (c->max && (*length < 0))\n\t\t{\n\t\tc->error=ERR_R_ASN1_LENGTH_MISMATCH;\n\t\treturn(0);\n\t\t}\n\tif (c->inf == (1|V_ASN1_CONSTRUCTED))\n\t\tc->slen= *length+ *(c->pp)-c->p;\n\tc->eos=0;\n\treturn(1);\n\t}', 'int ASN1_get_object(unsigned char **pp, long *plength, int *ptag, int *pclass,\n\t     long omax)\n\t{\n\tint i,ret;\n\tlong l;\n\tunsigned char *p= *pp;\n\tint tag,xclass,inf;\n\tlong max=omax;\n\tif (!max) goto err;\n\tret=(*p&V_ASN1_CONSTRUCTED);\n\txclass=(*p&V_ASN1_PRIVATE);\n\ti= *p&V_ASN1_PRIMITIVE_TAG;\n\tif (i == V_ASN1_PRIMITIVE_TAG)\n\t\t{\n\t\tp++;\n\t\tif (--max == 0) goto err;\n\t\tl=0;\n\t\twhile (*p&0x80)\n\t\t\t{\n\t\t\tl<<=7L;\n\t\t\tl|= *(p++)&0x7f;\n\t\t\tif (--max == 0) goto err;\n\t\t\t}\n\t\tl<<=7L;\n\t\tl|= *(p++)&0x7f;\n\t\ttag=(int)l;\n\t\t}\n\telse\n\t\t{\n\t\ttag=i;\n\t\tp++;\n\t\tif (--max == 0) goto err;\n\t\t}\n\t*ptag=tag;\n\t*pclass=xclass;\n\tif (!asn1_get_length(&p,&inf,plength,(int)max)) goto err;\n#if 0\n\tfprintf(stderr,"p=%d + *plength=%ld > omax=%ld + *pp=%d  (%d > %d)\\n",\n\t\t(int)p,*plength,omax,(int)*pp,(int)(p+ *plength),\n\t\t(int)(omax+ *pp));\n#endif\n#if 0\n\tif ((p+ *plength) > (omax+ *pp))\n\t\t{\n\t\tASN1err(ASN1_F_ASN1_GET_OBJECT,ASN1_R_TOO_LONG);\n\t\tret|=0x80;\n\t\t}\n#endif\n\t*pp=p;\n\treturn(ret|inf);\nerr:\n\tASN1err(ASN1_F_ASN1_GET_OBJECT,ASN1_R_HEADER_TOO_LONG);\n\treturn(0x80);\n\t}', 'ASN1_OCTET_STRING *d2i_ASN1_OCTET_STRING(ASN1_OCTET_STRING **a,\n\t     unsigned char **pp, long length)\n\t{\n\tASN1_OCTET_STRING *ret=NULL;\n\tret=(ASN1_OCTET_STRING *)d2i_ASN1_bytes((ASN1_STRING **)a,\n\t\tpp,length,V_ASN1_OCTET_STRING,V_ASN1_UNIVERSAL);\n\tif (ret == NULL)\n\t\t{\n\t\tASN1err(ASN1_F_D2I_ASN1_OCTET_STRING,ERR_R_NESTED_ASN1_ERROR);\n\t\treturn(NULL);\n\t\t}\n\treturn(ret);\n\t}', "ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, unsigned char **pp, long length,\n\t     int Ptag, int Pclass)\n\t{\n\tASN1_STRING *ret=NULL;\n\tunsigned char *p,*s;\n\tlong len;\n\tint inf,tag,xclass;\n\tint i=0;\n\tif ((a == NULL) || ((*a) == NULL))\n\t\t{\n\t\tif ((ret=ASN1_STRING_new()) == NULL) return(NULL);\n\t\t}\n\telse\n\t\tret=(*a);\n\tp= *pp;\n\tinf=ASN1_get_object(&p,&len,&tag,&xclass,length);\n\tif (inf & 0x80)\n\t\t{\n\t\ti=ASN1_R_BAD_OBJECT_HEADER;\n\t\tgoto err;\n\t\t}\n\tif (tag != Ptag)\n\t\t{\n\t\ti=ASN1_R_WRONG_TAG;\n\t\tgoto err;\n\t\t}\n\tif (inf & V_ASN1_CONSTRUCTED)\n\t\t{\n\t\tASN1_CTX c;\n\t\tc.pp=pp;\n\t\tc.p=p;\n\t\tc.inf=inf;\n\t\tc.slen=len;\n\t\tc.tag=Ptag;\n\t\tc.xclass=Pclass;\n\t\tc.max=(length == 0)?0:(p+length);\n\t\tif (!asn1_collate_primative(ret,&c))\n\t\t\tgoto err;\n\t\telse\n\t\t\t{\n\t\t\tp=c.p;\n\t\t\t}\n\t\t}\n\telse\n\t\t{\n\t\tif (len != 0)\n\t\t\t{\n\t\t\tif ((ret->length < len) || (ret->data == NULL))\n\t\t\t\t{\n\t\t\t\tif (ret->data != NULL) Free((char *)ret->data);\n\t\t\t\ts=(unsigned char *)Malloc((int)len + 1);\n\t\t\t\tif (s == NULL)\n\t\t\t\t\t{\n\t\t\t\t\ti=ERR_R_MALLOC_FAILURE;\n\t\t\t\t\tgoto err;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\telse\n\t\t\t\ts=ret->data;\n\t\t\tmemcpy(s,p,(int)len);\n\t\t\ts[len] = '\\0';\n\t\t\tp+=len;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\ts=NULL;\n\t\t\tif (ret->data != NULL) Free((char *)ret->data);\n\t\t\t}\n\t\tret->length=(int)len;\n\t\tret->data=s;\n\t\tret->type=Ptag;\n\t\t}\n\tif (a != NULL) (*a)=ret;\n\t*pp=p;\n\treturn(ret);\nerr:\n\tif ((ret != NULL) && ((a == NULL) || (*a != ret)))\n\t\tASN1_STRING_free(ret);\n\tASN1err(ASN1_F_D2I_ASN1_BYTES,i);\n\treturn(NULL);\n\t}", 'static int asn1_collate_primative(ASN1_STRING *a, ASN1_CTX *c)\n\t{\n\tASN1_STRING *os=NULL;\n\tBUF_MEM b;\n\tint num;\n\tb.length=0;\n\tb.max=0;\n\tb.data=NULL;\n\tif (a == NULL)\n\t\t{\n\t\tc->error=ERR_R_PASSED_NULL_PARAMETER;\n\t\tgoto err;\n\t\t}\n\tnum=0;\n\tfor (;;)\n\t\t{\n\t\tif (c->inf & 1)\n\t\t\t{\n\t\t\tc->eos=ASN1_check_infinite_end(&c->p,\n\t\t\t\t(long)(c->max-c->p));\n\t\t\tif (c->eos) break;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tif (c->slen <= 0) break;\n\t\t\t}\n\t\tc->q=c->p;\n\t\tif (d2i_ASN1_bytes(&os,&c->p,c->max-c->p,c->tag,c->xclass)\n\t\t\t== NULL)\n\t\t\t{\n\t\t\tc->error=ERR_R_ASN1_LIB;\n\t\t\tgoto err;\n\t\t\t}\n\t\tif (!BUF_MEM_grow(&b,num+os->length))\n\t\t\t{\n\t\t\tc->error=ERR_R_BUF_LIB;\n\t\t\tgoto err;\n\t\t\t}\n\t\tmemcpy(&(b.data[num]),os->data,os->length);\n\t\tif (!(c->inf & 1))\n\t\t\tc->slen-=(c->p-c->q);\n\t\tnum+=os->length;\n\t\t}\n\tif (!asn1_Finish(c)) goto err;\n\ta->length=num;\n\tif (a->data != NULL) Free(a->data);\n\ta->data=(unsigned char *)b.data;\n\tif (os != NULL) ASN1_STRING_free(os);\n\treturn(1);\nerr:\n\tASN1err(ASN1_F_ASN1_COLLATE_PRIMITIVE,c->error);\n\tif (os != NULL) ASN1_STRING_free(os);\n\tif (b.data != NULL) Free(b.data);\n\treturn(0);\n\t}', 'int ASN1_check_infinite_end(unsigned char **p, long len)\n\t{\n\tif (len <= 0)\n\t\treturn(1);\n\telse if ((len >= 2) && ((*p)[0] == 0) && ((*p)[1] == 0))\n\t\t{\n\t\t(*p)+=2;\n\t\treturn(1);\n\t\t}\n\treturn(0);\n\t}']