apps/pkcs8.c:219: error: BUFFER_OVERRUN_L3
  Offset: [1, +oo] Size: [0, +oo] by call to `PKCS12_decrypt_d2i`.
Showing all 18 steps of the trace


apps/pkcs8.c:205:9: Call
203.   	} else {
204.   		if(informat == FORMAT_PEM) 
205.   			p8 = PEM_read_bio_PKCS8(in, NULL, NULL);
               ^
206.   		else if(informat == FORMAT_ASN1)
207.   			p8 = d2i_PKCS8_bio(in, NULL);

crypto/pem/pem_all.c:421:3: Call
  419.   	{
  420.   	return((X509_SIG *)
  421.   		PEM_ASN1_read_bio((char *(*)())d2i_X509_SIG,
           ^
  422.   		PEM_STRING_PKCS8,bp,(char **)x,cb));
  423.   	}

crypto/pem/pem_lib.c:212:10: Call
    210.   		else if (strcmp(nm,PEM_STRING_PKCS8INF) == 0) {
    211.   			PKCS8_PRIV_KEY_INFO *p8inf;
    212.   			p8inf=d2i_PKCS8_PRIV_KEY_INFO(
                    ^
    213.   					(PKCS8_PRIV_KEY_INFO **) x, &p, len);
    214.   			ret = (char *)EVP_PKCS82PKEY(p8inf);

crypto/asn1/p8_pkey.c:99:1: Parameter `(*a)->version->length`
      97.   }
      98.   
      99. > PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO **a,
      100.   	     unsigned char **pp, long length)
      101.   {

apps/pkcs8.c:219:11: Call
217.   		}
218.   		EVP_read_pw_string(pass, 50, "Enter Password:", 0);
219.   		p8inf = M_PKCS8_decrypt(p8, pass, strlen(pass));
                 ^
220.   	}
221.   

crypto/pkcs12/p12_decr.c:110:1: Parameter `oct->length`
  108.    */
  109.   
  110. > char * PKCS12_decrypt_d2i (X509_ALGOR *algor, char * (*d2i)(),
  111.   	     void (*free_func)(), const char *pass, int passlen,
  112.   	     ASN1_OCTET_STRING *oct, int seq)

crypto/pkcs12/p12_decr.c:118:7: Call
  116.   	int outlen;
  117.   
  118.   	if (!PKCS12_pbe_crypt (algor, pass, passlen, oct->data, oct->length,
               ^
  119.   			       &out, &outlen, 0)) {
  120.   		PKCS12err(PKCS12_F_PKCS12_DECRYPT_D2I,PKCS12_R_PKCS12_PBE_CRYPT_ERROR);

crypto/pkcs12/p12_decr.c:71:1: Parameter `**data`
    69.    */
    70.   
    71. > unsigned char * PKCS12_pbe_crypt (X509_ALGOR *algor, const char *pass,
    72.   	     int passlen, unsigned char *in, int inlen, unsigned char **data,
    73.   	     int *datalen, int en_de)

crypto/pkcs12/p12_decr.c:123:2: Assignment
  121.   		return NULL;
  122.   	}
  123.   	p = out;
          ^
  124.   #ifdef DEBUG_DECRYPT
  125.   	{

crypto/pkcs12/p12_decr.c:136:30: Call
  134.   	}
  135.   #endif
  136.   	if (seq & 1) ret = (char *) d2i_ASN1_SET(NULL, &p, outlen, d2i,
                                      ^
  137.   				free_func, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL);
  138.   	else ret = d2i(NULL, &p, outlen);

crypto/asn1/a_set.c:154:1: Parameter `**pp`
    152.           }
    153.   
    154. > STACK *d2i_ASN1_SET(STACK **a, unsigned char **pp, long length,
    155.   	     char *(*func)(), void (*free_func)(), int ex_tag, int ex_class)
    156.   	{

crypto/asn1/a_set.c:165:2: Assignment
    163.   		ret=(*a);
    164.   
    165.   	c.p= *pp;
            ^
    166.   	c.max=(length == 0)?0:(c.p+length);
    167.   

crypto/asn1/a_set.c:168:8: Call
    166.   	c.max=(length == 0)?0:(c.p+length);
    167.   
    168.   	c.inf=ASN1_get_object(&c.p,&c.slen,&c.tag,&c.xclass,c.max-c.p);
                  ^
    169.   	if (c.inf & 0x80) goto err;
    170.   	if (ex_class != c.xclass)

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

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/asn1_lib.c:88:2: Assignment
      86.   	int i,ret;
      87.   	long l;
      88.   	unsigned char *p= *pp;
             ^
      89.   	int tag,xclass,inf;
      90.   	long max=omax;

crypto/asn1/asn1_lib.c:98:3: Assignment
      96.   	if (i == V_ASN1_PRIMITIVE_TAG)
      97.   		{		/* high-tag */
      98.   		p++;
               ^
      99.   		if (--max == 0) goto err;
      100.   		l=0;

crypto/asn1/asn1_lib.c:101:10: Array access: Offset: [1, +oo] Size: [0, +oo] by call to `PKCS12_decrypt_d2i` 
      99.   		if (--max == 0) goto err;
      100.   		l=0;
      101.   		while (*p&0x80)
                      ^
      102.   			{
      103.   			l<<=7L;

int ASN1_get_object(unsigned char **pp, long *plength, int *ptag, int *pclass,
	     long omax)
	{
	int i,ret;
	long l;
	unsigned char *p= *pp;
	int tag,xclass,inf;
	long max=omax;
	if (!max) goto err;
	ret=(*p&V_ASN1_CONSTRUCTED);
	xclass=(*p&V_ASN1_PRIVATE);
	i= *p&V_ASN1_PRIMITIVE_TAG;
	if (i == V_ASN1_PRIMITIVE_TAG)
		{
		p++;
		if (--max == 0) goto err;
		l=0;
		while (*p&0x80)
			{
			l<<=7L;
			l|= *(p++)&0x7f;
			if (--max == 0) goto err;
			}
		l<<=7L;
		l|= *(p++)&0x7f;
		tag=(int)l;
		}
	else
		{
		tag=i;
		p++;
		if (--max == 0) goto err;
		}
	*ptag=tag;
	*pclass=xclass;
	if (!asn1_get_length(&p,&inf,plength,(int)max)) goto err;
#if 0
	fprintf(stderr,"p=%d + *plength=%ld > omax=%ld + *pp=%d  (%d > %d)\n",
		(int)p,*plength,omax,(int)*pp,(int)(p+ *plength),
		(int)(omax+ *pp));
#endif
#if 0
	if ((p+ *plength) > (omax+ *pp))
		{
		ASN1err(ASN1_F_ASN1_GET_OBJECT,ASN1_R_TOO_LONG);
		ret|=0x80;
		}
#endif
	*pp=p;
	return(ret|inf);
err:
	ASN1err(ASN1_F_ASN1_GET_OBJECT,ASN1_R_HEADER_TOO_LONG);
	return(0x80);
	}
['int MAIN(int argc, char **argv)\n{\n\tchar **args, *infile = NULL, *outfile = NULL;\n\tBIO *in = NULL, *out = NULL;\n\tint topk8 = 0;\n\tint pbe_nid = -1;\n\tint iter = PKCS12_DEFAULT_ITER;\n\tint informat, outformat;\n\tint p8_broken = PKCS8_OK;\n\tint nocrypt = 0;\n\tX509_SIG *p8;\n\tPKCS8_PRIV_KEY_INFO *p8inf;\n\tEVP_PKEY *pkey;\n\tchar pass[50];\n\tint badarg = 0;\n\tif (bio_err == NULL) bio_err = BIO_new_fp (stderr, BIO_NOCLOSE);\n\tinformat=FORMAT_PEM;\n\toutformat=FORMAT_PEM;\n\tERR_load_crypto_strings();\n\tSSLeay_add_all_algorithms();\n\targs = argv + 1;\n\twhile (!badarg && *args && *args[0] == \'-\') {\n\t\tif (!strcmp(*args,"-inform")) {\n\t\t\tif (args[1]) {\n\t\t\t\targs++;\n\t\t\t\tinformat=str2fmt(*args);\n\t\t\t} else badarg = 1;\n\t\t} else if (!strcmp(*args,"-outform")) {\n\t\t\tif (args[1]) {\n\t\t\t\targs++;\n\t\t\t\toutformat=str2fmt(*args);\n\t\t\t} else badarg = 1;\n\t\t} else if (!strcmp (*args, "-topk8")) topk8 = 1;\n\t\telse if (!strcmp (*args, "-noiter")) iter = 1;\n\t\telse if (!strcmp (*args, "-nocrypt")) nocrypt = 1;\n\t\telse if (!strcmp (*args, "-nooct")) p8_broken = PKCS8_NO_OCTET;\n\t\telse if (!strcmp (*args, "-in")) {\n\t\t\tif (args[1]) {\n\t\t\t\targs++;\n\t\t\t\tinfile = *args;\n\t\t\t} else badarg = 1;\n\t\t} else if (!strcmp (*args, "-out")) {\n\t\t\tif (args[1]) {\n\t\t\t\targs++;\n\t\t\t\toutfile = *args;\n\t\t\t} else badarg = 1;\n\t\t} else badarg = 1;\n\t\targs++;\n\t}\n\tif (badarg) {\n\t\tBIO_printf (bio_err, "Usage pkcs8 [options]\\n");\n\t\tBIO_printf (bio_err, "where options are\\n");\n\t\tBIO_printf (bio_err, "-in file   input file\\n");\n\t\tBIO_printf (bio_err, "-inform X  input format (DER or PEM)\\n");\n\t\tBIO_printf (bio_err, "-outform X output format (DER or PEM)\\n");\n\t\tBIO_printf (bio_err, "-out file  output file\\n");\n\t\tBIO_printf (bio_err, "-topk8     output PKCS8 file\\n");\n\t\tBIO_printf (bio_err, "-nooct     use (broken) no octet form\\n");\n\t\tBIO_printf (bio_err, "-noiter    use 1 as iteration count\\n");\n\t\tBIO_printf (bio_err, "-nocrypt   use or expect unencrypted private key\\n");\n\t\treturn (1);\n\t}\n\tif (pbe_nid == -1) pbe_nid = NID_pbeWithMD5AndDES_CBC;\n\tif (infile) {\n\t\tif (!(in = BIO_new_file (infile, "rb"))) {\n\t\t\tBIO_printf (bio_err,\n\t\t\t\t "Can\'t open input file %s\\n", infile);\n\t\t\treturn (1);\n\t\t}\n\t} else in = BIO_new_fp (stdin, BIO_NOCLOSE);\n\tif (outfile) {\n\t\tif (!(out = BIO_new_file (outfile, "wb"))) {\n\t\t\tBIO_printf (bio_err,\n\t\t\t\t "Can\'t open output file %s\\n", outfile);\n\t\t\treturn (1);\n\t\t}\n\t} else out = BIO_new_fp (stdout, BIO_NOCLOSE);\n\tif (topk8) {\n\t\tif (!(pkey = PEM_read_bio_PrivateKey(in, NULL, NULL))) {\n\t\t\tBIO_printf (bio_err, "Error reading key\\n", outfile);\n\t\t\tERR_print_errors(bio_err);\n\t\t\treturn (1);\n\t\t}\n\t\tif (!(p8inf = EVP_PKEY2PKCS8(pkey))) {\n\t\t\tBIO_printf (bio_err, "Error converting key\\n", outfile);\n\t\t\tERR_print_errors(bio_err);\n\t\t\treturn (1);\n\t\t}\n\t\tPKCS8_set_broken(p8inf, p8_broken);\n\t\tif(nocrypt) {\n\t\t\tif(outformat == FORMAT_PEM)\n\t\t\t\tPEM_write_bio_PKCS8_PRIV_KEY_INFO(out, p8inf);\n\t\t\telse if(outformat == FORMAT_ASN1)\n\t\t\t\ti2d_PKCS8_PRIV_KEY_INFO_bio(out, p8inf);\n\t\t\telse {\n\t\t\t\tBIO_printf(bio_err, "Bad format specified for key\\n");\n\t\t\t\treturn (1);\n\t\t\t}\n\t\t} else {\n\t\t\tEVP_read_pw_string(pass, 50, "Enter Encryption Password:", 1);\n\t\t\tif (!(p8 = PKCS8_encrypt(pbe_nid, pass, strlen(pass),\n\t\t\t\t\t NULL, 0, iter, p8inf))) {\n\t\t\t\tBIO_printf (bio_err, "Error encrypting key\\n",\n\t\t\t\t\t\t\t\t outfile);\n\t\t\t\tERR_print_errors(bio_err);\n\t\t\t\treturn (1);\n\t\t\t}\n\t\t\tif(outformat == FORMAT_PEM)\n\t\t\t\tPEM_write_bio_PKCS8 (out, p8);\n\t\t\telse if(outformat == FORMAT_ASN1)\n\t\t\t\ti2d_PKCS8_bio(out, p8);\n\t\t\telse {\n\t\t\t\tBIO_printf(bio_err, "Bad format specified for key\\n");\n\t\t\t\treturn (1);\n\t\t\t}\n\t\t\tX509_SIG_free(p8);\n\t\t}\n\t\tPKCS8_PRIV_KEY_INFO_free (p8inf);\n\t\treturn (0);\n\t}\n\tif(nocrypt) {\n\t\tif(informat == FORMAT_PEM)\n\t\t\tp8inf = PEM_read_bio_PKCS8_PRIV_KEY_INFO(in,NULL,NULL);\n\t\telse if(informat == FORMAT_ASN1)\n\t\t\tp8inf = d2i_PKCS8_PRIV_KEY_INFO_bio(in, NULL);\n\t\telse {\n\t\t\tBIO_printf(bio_err, "Bad format specified for key\\n");\n\t\t\treturn (1);\n\t\t}\n\t} else {\n\t\tif(informat == FORMAT_PEM)\n\t\t\tp8 = PEM_read_bio_PKCS8(in, NULL, NULL);\n\t\telse if(informat == FORMAT_ASN1)\n\t\t\tp8 = d2i_PKCS8_bio(in, NULL);\n\t\telse {\n\t\t\tBIO_printf(bio_err, "Bad format specified for key\\n");\n\t\t\treturn (1);\n\t\t}\n\t\tif (!p8) {\n\t\t\tBIO_printf (bio_err, "Error reading key\\n", outfile);\n\t\t\tERR_print_errors(bio_err);\n\t\t\treturn (1);\n\t\t}\n\t\tEVP_read_pw_string(pass, 50, "Enter Password:", 0);\n\t\tp8inf = M_PKCS8_decrypt(p8, pass, strlen(pass));\n\t}\n\tif (!p8inf) {\n\t\tBIO_printf(bio_err, "Error decrypting key\\n", outfile);\n\t\tERR_print_errors(bio_err);\n\t\treturn (1);\n\t}\n\tif (!(pkey = EVP_PKCS82PKEY(p8inf))) {\n\t\tBIO_printf(bio_err, "Error converting key\\n", outfile);\n\t\tERR_print_errors(bio_err);\n\t\treturn (1);\n\t}\n\tif (p8inf->broken) {\n\t\tBIO_printf(bio_err, "Warning: broken key encoding: ");\n\t\tswitch (p8inf->broken) {\n\t\t\tcase PKCS8_NO_OCTET:\n\t\t\tBIO_printf(bio_err, "No Octet String\\n");\n\t\t\tbreak;\n\t\t\tdefault:\n\t\t\tBIO_printf(bio_err, "Unknown broken type\\n");\n\t\t\tbreak;\n\t\t}\n\t}\n\tPKCS8_PRIV_KEY_INFO_free(p8inf);\n\tPEM_write_bio_PrivateKey(out, pkey, NULL, NULL, 0, NULL);\n\treturn (0);\n}', 'X509_SIG *PEM_read_bio_PKCS8(BIO *bp,\n\t     X509_SIG **x, pem_password_cb *cb)\n\t{\n\treturn((X509_SIG *)\n\t\tPEM_ASN1_read_bio((char *(*)())d2i_X509_SIG,\n\t\tPEM_STRING_PKCS8,bp,(char **)x,cb));\n\t}', 'char *PEM_ASN1_read_bio(char *(*d2i)(), const char *name, BIO *bp, char **x,\n\t     pem_password_cb *cb)\n\t{\n\tEVP_CIPHER_INFO cipher;\n\tchar *nm=NULL,*header=NULL;\n\tunsigned char *p=NULL,*data=NULL;\n\tlong len;\n\tchar *ret=NULL;\n\tfor (;;)\n\t\t{\n\t\tif (!PEM_read_bio(bp,&nm,&header,&data,&len)) return(NULL);\n\t\tif (\t(strcmp(nm,name) == 0) ||\n\t\t\t((strcmp(nm,PEM_STRING_RSA) == 0) &&\n\t\t\t (strcmp(name,PEM_STRING_EVP_PKEY) == 0)) ||\n\t\t\t((strcmp(nm,PEM_STRING_DSA) == 0) &&\n\t\t\t (strcmp(name,PEM_STRING_EVP_PKEY) == 0)) ||\n\t\t\t((strcmp(nm,PEM_STRING_PKCS8) == 0) &&\n\t\t\t (strcmp(name,PEM_STRING_EVP_PKEY) == 0)) ||\n\t\t\t((strcmp(nm,PEM_STRING_PKCS8INF) == 0) &&\n\t\t\t (strcmp(name,PEM_STRING_EVP_PKEY) == 0)) ||\n\t\t\t((strcmp(nm,PEM_STRING_X509_OLD) == 0) &&\n\t\t\t (strcmp(name,PEM_STRING_X509) == 0)) ||\n\t\t\t((strcmp(nm,PEM_STRING_X509_REQ_OLD) == 0) &&\n\t\t\t (strcmp(name,PEM_STRING_X509_REQ) == 0))\n\t\t\t)\n\t\t\tbreak;\n\t\tFree(nm);\n\t\tFree(header);\n\t\tFree(data);\n\t\t}\n\tif (!PEM_get_EVP_CIPHER_INFO(header,&cipher)) goto err;\n\tif (!PEM_do_header(&cipher,data,&len,cb)) goto err;\n\tp=data;\n\tif (strcmp(name,PEM_STRING_EVP_PKEY) == 0) {\n\t\tif (strcmp(nm,PEM_STRING_RSA) == 0)\n\t\t\tret=d2i(EVP_PKEY_RSA,x,&p,len);\n\t\telse if (strcmp(nm,PEM_STRING_DSA) == 0)\n\t\t\tret=d2i(EVP_PKEY_DSA,x,&p,len);\n\t\telse if (strcmp(nm,PEM_STRING_PKCS8INF) == 0) {\n\t\t\tPKCS8_PRIV_KEY_INFO *p8inf;\n\t\t\tp8inf=d2i_PKCS8_PRIV_KEY_INFO(\n\t\t\t\t\t(PKCS8_PRIV_KEY_INFO **) x, &p, len);\n\t\t\tret = (char *)EVP_PKCS82PKEY(p8inf);\n\t\t\tPKCS8_PRIV_KEY_INFO_free(p8inf);\n\t\t} else if (strcmp(nm,PEM_STRING_PKCS8) == 0) {\n\t\t\tPKCS8_PRIV_KEY_INFO *p8inf;\n\t\t\tX509_SIG *p8;\n\t\t\tint klen;\n\t\t\tchar psbuf[PEM_BUFSIZE];\n\t\t\tp8 = d2i_X509_SIG((X509_SIG **)x, &p, len);\n\t\t\tif(!p8) goto p8err;\n\t\t\tif (cb) klen=cb(psbuf,PEM_BUFSIZE,0);\n\t\t\telse klen=def_callback(psbuf,PEM_BUFSIZE,0);\n\t\t\tif (klen <= 0) {\n\t\t\t\tPEMerr(PEM_F_PEM_ASN1_READ_BIO,\n\t\t\t\t\t\tPEM_R_BAD_PASSWORD_READ);\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t\tp8inf = M_PKCS8_decrypt(p8, psbuf, klen);\n\t\t\tX509_SIG_free(p8);\n\t\t\tif(!p8inf) goto p8err;\n\t\t\tret = (char *)EVP_PKCS82PKEY(p8inf);\n\t\t\tPKCS8_PRIV_KEY_INFO_free(p8inf);\n\t\t}\n\t} else\tret=d2i(x,&p,len);\np8err:\n\tif (ret == NULL)\n\t\tPEMerr(PEM_F_PEM_ASN1_READ_BIO,ERR_R_ASN1_LIB);\nerr:\n\tFree(nm);\n\tFree(header);\n\tFree(data);\n\treturn(ret);\n\t}', 'PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO **a,\n\t     unsigned char **pp, long length)\n{\n\tM_ASN1_D2I_vars(a,PKCS8_PRIV_KEY_INFO *,PKCS8_PRIV_KEY_INFO_new);\n\tM_ASN1_D2I_Init();\n\tM_ASN1_D2I_start_sequence();\n\tM_ASN1_D2I_get (ret->version, d2i_ASN1_INTEGER);\n\tM_ASN1_D2I_get (ret->pkeyalg, d2i_X509_ALGOR);\n\tM_ASN1_D2I_get (ret->pkey, d2i_ASN1_TYPE);\n\tM_ASN1_D2I_get_IMP_set_opt_type(X509_ATTRIBUTE, ret->attributes,\n\t\t\t\t\td2i_X509_ATTRIBUTE,\n\t\t\t\t\tX509_ATTRIBUTE_free, 0);\n\tif (ASN1_TYPE_get(ret->pkey) == V_ASN1_SEQUENCE)\n\t\t\t\t\t\tret->broken = PKCS8_NO_OCTET;\n\tM_ASN1_D2I_Finish(a, PKCS8_PRIV_KEY_INFO_free, ASN1_F_D2I_PKCS8_PRIV_KEY_INFO);\n}', 'char * PKCS12_decrypt_d2i (X509_ALGOR *algor, char * (*d2i)(),\n\t     void (*free_func)(), const char *pass, int passlen,\n\t     ASN1_OCTET_STRING *oct, int seq)\n{\n\tunsigned char *out, *p;\n\tchar *ret;\n\tint outlen;\n\tif (!PKCS12_pbe_crypt (algor, pass, passlen, oct->data, oct->length,\n\t\t\t       &out, &outlen, 0)) {\n\t\tPKCS12err(PKCS12_F_PKCS12_DECRYPT_D2I,PKCS12_R_PKCS12_PBE_CRYPT_ERROR);\n\t\treturn NULL;\n\t}\n\tp = out;\n#ifdef DEBUG_DECRYPT\n\t{\n\t\tFILE *op;\n\t\tchar fname[30];\n\t\tstatic int fnm = 1;\n\t\tsprintf(fname, "DER%d", fnm++);\n\t\top = fopen(fname, "wb");\n\t\tfwrite (p, 1, outlen, op);\n\t\tfclose(op);\n\t}\n#endif\n\tif (seq & 1) ret = (char *) d2i_ASN1_SET(NULL, &p, outlen, d2i,\n\t\t\t\tfree_func, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL);\n\telse ret = d2i(NULL, &p, outlen);\n\tif (seq & 2) memset(out, 0, outlen);\n\tif(!ret) PKCS12err(PKCS12_F_PKCS12_DECRYPT_D2I,PKCS12_R_DECODE_ERROR);\n\tFree (out);\n\treturn ret;\n}', 'unsigned char * PKCS12_pbe_crypt (X509_ALGOR *algor, const char *pass,\n\t     int passlen, unsigned char *in, int inlen, unsigned char **data,\n\t     int *datalen, int en_de)\n{\n\tunsigned char *out;\n\tint outlen, i;\n\tEVP_CIPHER_CTX ctx;\n\tif(!(out = Malloc (inlen + 8))) {\n\t\tPKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,ERR_R_MALLOC_FAILURE);\n\t\treturn NULL;\n\t}\n        if (!EVP_PBE_CipherInit (algor->algorithm, pass, passlen,\n\t\t\t\t\t algor->parameter, &ctx, en_de)) {\n\t\tPKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR);\n\t\treturn NULL;\n\t}\n\tEVP_CipherUpdate (&ctx, out, &i, in, inlen);\n\toutlen = i;\n\tif(!EVP_CipherFinal (&ctx, out + i, &i)) {\n\t\tFree (out);\n\t\tPKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,PKCS12_R_PKCS12_CIPHERFINAL_ERROR);\n\t\treturn NULL;\n\t}\n\toutlen += i;\n\tif (datalen) *datalen = outlen;\n\tif (data) *data = out;\n\treturn out;\n}', 'STACK *d2i_ASN1_SET(STACK **a, unsigned char **pp, long length,\n\t     char *(*func)(), void (*free_func)(), int ex_tag, int ex_class)\n\t{\n\tASN1_CTX c;\n\tSTACK *ret=NULL;\n\tif ((a == NULL) || ((*a) == NULL))\n\t\t{ if ((ret=sk_new(NULL)) == NULL) goto err; }\n\telse\n\t\tret=(*a);\n\tc.p= *pp;\n\tc.max=(length == 0)?0:(c.p+length);\n\tc.inf=ASN1_get_object(&c.p,&c.slen,&c.tag,&c.xclass,c.max-c.p);\n\tif (c.inf & 0x80) goto err;\n\tif (ex_class != c.xclass)\n\t\t{\n\t\tASN1err(ASN1_F_D2I_ASN1_SET,ASN1_R_BAD_CLASS);\n\t\tgoto err;\n\t\t}\n\tif (ex_tag != c.tag)\n\t\t{\n\t\tASN1err(ASN1_F_D2I_ASN1_SET,ASN1_R_BAD_TAG);\n\t\tgoto err;\n\t\t}\n\tif ((c.slen+c.p) > c.max)\n\t\t{\n\t\tASN1err(ASN1_F_D2I_ASN1_SET,ASN1_R_LENGTH_ERROR);\n\t\tgoto err;\n\t\t}\n\tif (c.inf == (V_ASN1_CONSTRUCTED+1))\n\t\tc.slen=length+ *pp-c.p;\n\tc.max=c.p+c.slen;\n\twhile (c.p < c.max)\n\t\t{\n\t\tchar *s;\n\t\tif (M_ASN1_D2I_end_sequence()) break;\n\t\tif ((s=func(NULL,&c.p,c.slen,c.max-c.p)) == NULL)\n\t\t\t{\n\t\t\tASN1err(ASN1_F_D2I_ASN1_SET,ASN1_R_ERROR_PARSING_SET_ELEMENT);\n\t\t\tasn1_add_error(*pp,(int)(c.q- *pp));\n\t\t\tgoto err;\n\t\t\t}\n\t\tif (!sk_push(ret,s)) goto err;\n\t\t}\n\tif (a != NULL) (*a)=ret;\n\t*pp=c.p;\n\treturn(ret);\nerr:\n\tif ((ret != NULL) && ((a == NULL) || (*a != ret)))\n\t\t{\n\t\tif (free_func != NULL)\n\t\t\tsk_pop_free(ret,free_func);\n\t\telse\n\t\t\tsk_free(ret);\n\t\t}\n\treturn(NULL);\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}']