crypto/rsa/rsa_eay.c:287: error: BUFFER_OVERRUN_L3
  Offset: [7, +oo] (⇐ [0, +oo] + 7) Size: [0, +oo] by call to `BN_BLINDING_convert`.
Showing all 17 steps of the trace


crypto/rsa/rsa_eay.c:282:6: Call
280.   
281.   	/* make data into a big number */
282.   	if (BN_bin2bn(from,(int)flen,&f) == NULL) goto err;
            ^
283.   
284.   	if ((rsa->flags & RSA_FLAG_BLINDING) && (rsa->blinding == NULL))

crypto/bn/bn_lib.c:574:1: Parameter `*ret->d`
  572.   
  573.   /* ignore negative */
  574. > BIGNUM *BN_bin2bn(unsigned char *s, int len, BIGNUM *ret)
  575.   	{
  576.   	unsigned int i,m;

crypto/rsa/rsa_eay.c:287:8: Call
285.   		RSA_blinding_on(rsa,ctx);
286.   	if (rsa->flags & RSA_FLAG_BLINDING)
287.   		if (!BN_BLINDING_convert(&f,rsa->blinding,ctx)) goto err;
              ^
288.   
289.   	/* do the decrypt */

crypto/bn/bn_blind.c:115:1: Parameter `*n->d`
  113.   	}
  114.   
  115. > int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx)
  116.   	{
  117.   	bn_check_top(n);

crypto/bn/bn_blind.c:124:9: Call
  122.   		return(0);
  123.   		}
  124.   	return(BN_mod_mul(n,n,b->A,b->mod,ctx));
                 ^
  125.   	}
  126.   

crypto/bn/bn_exp.c:66:1: Parameter `*ret->d`
    64.   
    65.   /* slow but works */
    66. > int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, BIGNUM *m, BN_CTX *ctx)
    67.   	{
    68.   	BIGNUM *t;

crypto/bn/bn_exp.c:80:7: Call
    78.   	else
    79.   		{ if (!BN_mul(t,a,b,ctx)) goto err; }
    80.   	if (!BN_mod(ret,t,m,ctx)) goto err;
                ^
    81.   	r=1;
    82.   err:

crypto/bn/bn_div.c:286:1: Parameter `*rem->d`
      284.   
      285.   /* rem != m */
      286. > int BN_mod(BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx)
      287.   	{
      288.   #if 0 /* The old slow way */

crypto/bn/bn_div.c:312:9: Call
      310.   	return(1);
      311.   #else
      312.   	return(BN_div(NULL,rem,m,d,ctx));
                     ^
      313.   #endif
      314.   	}

crypto/bn/bn_div.c:120:1: Parameter `*rm->d`
        118.   #else
        119.   
        120. > int BN_div(BIGNUM *dv, BIGNUM *rm, BIGNUM *num, BIGNUM *divisor,
        121.   	     BN_CTX *ctx)
        122.   	{

crypto/bn/bn_div.c:141:10: Call
        139.   		{
        140.   		if (rm != NULL)
        141.   			{ if (BN_copy(rm,num) == NULL) return(0); }
                        ^
        142.   		if (dv != NULL) BN_zero(dv);
        143.   		return(1);

crypto/bn/bn_lib.c:454:1: Parameter `*a->d`
          452.   	}
          453.   
          454. > BIGNUM *BN_copy(BIGNUM *a, BIGNUM *b)
          455.   	{
          456.   	int i;

crypto/bn/bn_lib.c:462:6: Call
          460.   
          461.   	if (a == b) return(a);
          462.   	if (bn_wexpand(a,b->top) == NULL) return(NULL);
                      ^
          463.   
          464.   #if 1

crypto/bn/bn_lib.c:344:1: <Length trace>
342.   	}
343.   
344. > BIGNUM *bn_expand2(BIGNUM *b, int words)
345.   	{
346.   	BN_ULONG *A,*B,*a;

crypto/bn/bn_lib.c:344:1: Parameter `*b->d`
            342.   	}
            343.   
            344. > BIGNUM *bn_expand2(BIGNUM *b, int words)
            345.   	{
            346.   	BN_ULONG *A,*B,*a;

crypto/bn/bn_lib.c:367:3: Assignment
            365.   memset(A,0x5c,sizeof(BN_ULONG)*(words+1));
            366.   #if 1
            367.   		B=b->d;
                     ^
            368.   		/* Check if the previous number needs to be copied */
            369.   		if (B != NULL)

crypto/bn/bn_lib.c:377:43: Array access: Offset: [7, +oo] (⇐ [0, +oo] + 7) Size: [0, +oo] by call to `BN_BLINDING_convert` 
            375.   				{
            376.   				A[0]=B[0]; A[1]=B[1]; A[2]=B[2]; A[3]=B[3];
            377.   				A[4]=B[4]; A[5]=B[5]; A[6]=B[6]; A[7]=B[7];
                                                             ^
            378.   				A+=8;
            379.   				B+=8;

BIGNUM *bn_expand2(BIGNUM *b, int words)
	{
	BN_ULONG *A,*B,*a;
	int i,j;
	bn_check_top(b);
	if (words > b->max)
		{
		bn_check_top(b);
		if (BN_get_flags(b,BN_FLG_STATIC_DATA))
			{
			BNerr(BN_F_BN_EXPAND2,BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);
			return(NULL);
			}
		a=A=(BN_ULONG *)Malloc(sizeof(BN_ULONG)*(words+1));
		if (A == NULL)
			{
			BNerr(BN_F_BN_EXPAND2,ERR_R_MALLOC_FAILURE);
			return(NULL);
			}
memset(A,0x5c,sizeof(BN_ULONG)*(words+1));
#if 1
		B=b->d;
		if (B != NULL)
			{
			for (i=b->top&(~7); i>0; i-=8)
				{
				A[0]=B[0]; A[1]=B[1]; A[2]=B[2]; A[3]=B[3];
				A[4]=B[4]; A[5]=B[5]; A[6]=B[6]; A[7]=B[7];
				A+=8;
				B+=8;
				}
			switch (b->top&7)
				{
			case 7:
				A[6]=B[6];
			case 6:
				A[5]=B[5];
			case 5:
				A[4]=B[4];
			case 4:
				A[3]=B[3];
			case 3:
				A[2]=B[2];
			case 2:
				A[1]=B[1];
			case 1:
				A[0]=B[0];
			case 0:
				;
				}
			Free(b->d);
			}
		b->d=a;
		b->max=words;
		B= &(b->d[b->top]);
		j=(b->max - b->top) & ~7;
		for (i=0; i<j; i+=8)
			{
			B[0]=0; B[1]=0; B[2]=0; B[3]=0;
			B[4]=0; B[5]=0; B[6]=0; B[7]=0;
			B+=8;
			}
		j=(b->max - b->top) & 7;
		for (i=0; i<j; i++)
			{
			B[0]=0;
			B++;
			}
#else
			memcpy(a->d,b->d,sizeof(b->d[0])*b->top);
#endif
		}
	return(b);
	}
['static int RSA_eay_private_decrypt(int flen, unsigned char *from,\n\t     unsigned char *to, RSA *rsa, int padding)\n\t{\n\tBIGNUM f,ret;\n\tint j,num=0,r= -1;\n\tunsigned char *p;\n\tunsigned char *buf=NULL;\n\tBN_CTX *ctx=NULL;\n\tBN_init(&f);\n\tBN_init(&ret);\n\tctx=BN_CTX_new();\n\tif (ctx == NULL) goto err;\n\tnum=BN_num_bytes(rsa->n);\n\tif ((buf=(unsigned char *)Malloc(num)) == NULL)\n\t\t{\n\t\tRSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,ERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t\t}\n\tif (flen > num)\n\t\t{\n\t\tRSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,RSA_R_DATA_GREATER_THAN_MOD_LEN);\n\t\tgoto err;\n\t\t}\n\tif (BN_bin2bn(from,(int)flen,&f) == NULL) goto err;\n\tif ((rsa->flags & RSA_FLAG_BLINDING) && (rsa->blinding == NULL))\n\t\tRSA_blinding_on(rsa,ctx);\n\tif (rsa->flags & RSA_FLAG_BLINDING)\n\t\tif (!BN_BLINDING_convert(&f,rsa->blinding,ctx)) goto err;\n\tif (\t(rsa->p != NULL) &&\n\t\t(rsa->q != NULL) &&\n\t\t(rsa->dmp1 != NULL) &&\n\t\t(rsa->dmq1 != NULL) &&\n\t\t(rsa->iqmp != NULL))\n\t\t{ if (!rsa->meth->rsa_mod_exp(&ret,&f,rsa)) goto err; }\n\telse\n\t\t{\n\t\tif (!rsa->meth->bn_mod_exp(&ret,&f,rsa->d,rsa->n,ctx,NULL))\n\t\t\tgoto err;\n\t\t}\n\tif (rsa->flags & RSA_FLAG_BLINDING)\n\t\tif (!BN_BLINDING_invert(&ret,rsa->blinding,ctx)) goto err;\n\tp=buf;\n\tj=BN_bn2bin(&ret,p);\n\tswitch (padding)\n\t\t{\n\tcase RSA_PKCS1_PADDING:\n\t\tr=RSA_padding_check_PKCS1_type_2(to,num,buf,j,num);\n\t\tbreak;\n        case RSA_PKCS1_OAEP_PADDING:\n\t        r=RSA_padding_check_PKCS1_OAEP(to,num,buf,j,num,NULL,0);\n                break;\n \tcase RSA_SSLV23_PADDING:\n\t\tr=RSA_padding_check_SSLv23(to,num,buf,j,num);\n\t\tbreak;\n\tcase RSA_NO_PADDING:\n\t\tr=RSA_padding_check_none(to,num,buf,j,num);\n\t\tbreak;\n\tdefault:\n\t\tRSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,RSA_R_UNKNOWN_PADDING_TYPE);\n\t\tgoto err;\n\t\t}\n\tif (r < 0)\n\t\tRSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,RSA_R_PADDING_CHECK_FAILED);\nerr:\n\tif (ctx != NULL) BN_CTX_free(ctx);\n\tBN_clear_free(&f);\n\tBN_clear_free(&ret);\n\tif (buf != NULL)\n\t\t{\n\t\tmemset(buf,0,num);\n\t\tFree(buf);\n\t\t}\n\treturn(r);\n\t}', 'BIGNUM *BN_bin2bn(unsigned char *s, int len, BIGNUM *ret)\n\t{\n\tunsigned int i,m;\n\tunsigned int n;\n\tBN_ULONG l;\n\tif (ret == NULL) ret=BN_new();\n\tif (ret == NULL) return(NULL);\n\tl=0;\n\tn=len;\n\tif (n == 0)\n\t\t{\n\t\tret->top=0;\n\t\treturn(ret);\n\t\t}\n\tif (bn_expand(ret,(int)(n+2)*8) == NULL)\n\t\treturn(NULL);\n\ti=((n-1)/BN_BYTES)+1;\n\tm=((n-1)%(BN_BYTES));\n\tret->top=i;\n\twhile (n-- > 0)\n\t\t{\n\t\tl=(l<<8L)| *(s++);\n\t\tif (m-- == 0)\n\t\t\t{\n\t\t\tret->d[--i]=l;\n\t\t\tl=0;\n\t\t\tm=BN_BYTES-1;\n\t\t\t}\n\t\t}\n\tbn_fix_top(ret);\n\treturn(ret);\n\t}', 'int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx)\n\t{\n\tbn_check_top(n);\n\tif ((b->A == NULL) || (b->Ai == NULL))\n\t\t{\n\t\tBNerr(BN_F_BN_BLINDING_CONVERT,BN_R_NOT_INITIALIZED);\n\t\treturn(0);\n\t\t}\n\treturn(BN_mod_mul(n,n,b->A,b->mod,ctx));\n\t}', 'int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, BIGNUM *m, BN_CTX *ctx)\n\t{\n\tBIGNUM *t;\n\tint r=0;\n\tbn_check_top(a);\n\tbn_check_top(b);\n\tbn_check_top(m);\n\tt= &(ctx->bn[ctx->tos++]);\n\tif (a == b)\n\t\t{ if (!BN_sqr(t,a,ctx)) goto err; }\n\telse\n\t\t{ if (!BN_mul(t,a,b,ctx)) goto err; }\n\tif (!BN_mod(ret,t,m,ctx)) goto err;\n\tr=1;\nerr:\n\tctx->tos--;\n\treturn(r);\n\t}', 'int BN_mod(BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx)\n\t{\n#if 0\n\tint i,nm,nd;\n\tBIGNUM *dv;\n\tif (BN_ucmp(m,d) < 0)\n\t\treturn((BN_copy(rem,m) == NULL)?0:1);\n\tdv= &(ctx->bn[ctx->tos]);\n\tif (!BN_copy(rem,m)) return(0);\n\tnm=BN_num_bits(rem);\n\tnd=BN_num_bits(d);\n\tif (!BN_lshift(dv,d,nm-nd)) return(0);\n\tfor (i=nm-nd; i>=0; i--)\n\t\t{\n\t\tif (BN_cmp(rem,dv) >= 0)\n\t\t\t{\n\t\t\tif (!BN_sub(rem,rem,dv)) return(0);\n\t\t\t}\n\t\tif (!BN_rshift1(dv,dv)) return(0);\n\t\t}\n\treturn(1);\n#else\n\treturn(BN_div(NULL,rem,m,d,ctx));\n#endif\n\t}', 'int BN_div(BIGNUM *dv, BIGNUM *rm, BIGNUM *num, BIGNUM *divisor,\n\t     BN_CTX *ctx)\n\t{\n\tint norm_shift,i,j,loop;\n\tBIGNUM *tmp,wnum,*snum,*sdiv,*res;\n\tBN_ULONG *resp,*wnump;\n\tBN_ULONG d0,d1;\n\tint num_n,div_n;\n\tbn_check_top(num);\n\tbn_check_top(divisor);\n\tif (BN_is_zero(divisor))\n\t\t{\n\t\tBNerr(BN_F_BN_DIV,BN_R_DIV_BY_ZERO);\n\t\treturn(0);\n\t\t}\n\tif (BN_ucmp(num,divisor) < 0)\n\t\t{\n\t\tif (rm != NULL)\n\t\t\t{ if (BN_copy(rm,num) == NULL) return(0); }\n\t\tif (dv != NULL) BN_zero(dv);\n\t\treturn(1);\n\t\t}\n\ttmp= &(ctx->bn[ctx->tos]);\n\ttmp->neg=0;\n\tsnum= &(ctx->bn[ctx->tos+1]);\n\tsdiv= &(ctx->bn[ctx->tos+2]);\n\tif (dv == NULL)\n\t\tres= &(ctx->bn[ctx->tos+3]);\n\telse\tres=dv;\n\tnorm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2);\n\tBN_lshift(sdiv,divisor,norm_shift);\n\tsdiv->neg=0;\n\tnorm_shift+=BN_BITS2;\n\tBN_lshift(snum,num,norm_shift);\n\tsnum->neg=0;\n\tdiv_n=sdiv->top;\n\tnum_n=snum->top;\n\tloop=num_n-div_n;\n\tBN_init(&wnum);\n\twnum.d=\t &(snum->d[loop]);\n\twnum.top= div_n;\n\twnum.max= snum->max+1;\n\td0=sdiv->d[div_n-1];\n\td1=(div_n == 1)?0:sdiv->d[div_n-2];\n\twnump= &(snum->d[num_n-1]);\n\tres->neg= (num->neg^divisor->neg);\n\tif (!bn_wexpand(res,(loop+1))) goto err;\n\tres->top=loop;\n\tresp= &(res->d[loop-1]);\n\tif (!bn_wexpand(tmp,(div_n+1))) goto err;\n\tif (BN_ucmp(&wnum,sdiv) >= 0)\n\t\t{\n\t\tif (!BN_usub(&wnum,&wnum,sdiv)) goto err;\n\t\t*resp=1;\n\t\tres->d[res->top-1]=1;\n\t\t}\n\telse\n\t\tres->top--;\n\tresp--;\n\tfor (i=0; i<loop-1; i++)\n\t\t{\n\t\tBN_ULONG q,n0,n1;\n\t\tBN_ULONG l0;\n\t\twnum.d--; wnum.top++;\n\t\tn0=wnump[0];\n\t\tn1=wnump[-1];\n\t\tif (n0 == d0)\n\t\t\tq=BN_MASK2;\n\t\telse\n\t\t\tq=bn_div_words(n0,n1,d0);\n\t\t{\n#ifdef BN_LLONG\n\t\tBN_ULLONG t1,t2,rem;\n\t\tt1=((BN_ULLONG)n0<<BN_BITS2)|n1;\n\t\tfor (;;)\n\t\t\t{\n\t\t\tt2=(BN_ULLONG)d1*q;\n\t\t\trem=t1-(BN_ULLONG)q*d0;\n\t\t\tif ((rem>>BN_BITS2) ||\n\t\t\t\t(t2 <= ((BN_ULLONG)(rem<<BN_BITS2)+wnump[-2])))\n\t\t\t\tbreak;\n\t\t\tq--;\n\t\t\t}\n#else\n\t\tBN_ULONG t1l,t1h,t2l,t2h,t3l,t3h,ql,qh,t3t;\n\t\tt1h=n0;\n\t\tt1l=n1;\n\t\tfor (;;)\n\t\t\t{\n\t\t\tt2l=LBITS(d1); t2h=HBITS(d1);\n\t\t\tql =LBITS(q);  qh =HBITS(q);\n\t\t\tmul64(t2l,t2h,ql,qh);\n\t\t\tt3t=LBITS(d0); t3h=HBITS(d0);\n\t\t\tmul64(t3t,t3h,ql,qh);\n\t\t\tt3l=(t1l-t3t)&BN_MASK2;\n\t\t\tif (t3l > t1l) t3h++;\n\t\t\tt3h=(t1h-t3h)&BN_MASK2;\n\t\t\tif (t3h) break;\n\t\t\tif (t2h < t3l) break;\n\t\t\tif ((t2h == t3l) && (t2l <= wnump[-2])) break;\n\t\t\tq--;\n\t\t\t}\n#endif\n\t\t}\n\t\tl0=bn_mul_words(tmp->d,sdiv->d,div_n,q);\n\t\ttmp->d[div_n]=l0;\n\t\tfor (j=div_n+1; j>0; j--)\n\t\t\tif (tmp->d[j-1]) break;\n\t\ttmp->top=j;\n\t\tj=wnum.top;\n\t\tBN_sub(&wnum,&wnum,tmp);\n\t\tsnum->top=snum->top+wnum.top-j;\n\t\tif (wnum.neg)\n\t\t\t{\n\t\t\tq--;\n\t\t\tj=wnum.top;\n\t\t\tBN_add(&wnum,&wnum,sdiv);\n\t\t\tsnum->top+=wnum.top-j;\n\t\t\t}\n\t\t*(resp--)=q;\n\t\twnump--;\n\t\t}\n\tif (rm != NULL)\n\t\t{\n\t\tBN_rshift(rm,snum,norm_shift);\n\t\trm->neg=num->neg;\n\t\t}\n\treturn(1);\nerr:\n\treturn(0);\n\t}', 'BIGNUM *BN_copy(BIGNUM *a, BIGNUM *b)\n\t{\n\tint i;\n\tBN_ULONG *A,*B;\n\tbn_check_top(b);\n\tif (a == b) return(a);\n\tif (bn_wexpand(a,b->top) == NULL) return(NULL);\n#if 1\n\tA=a->d;\n\tB=b->d;\n\tfor (i=b->top&(~7); i>0; i-=8)\n\t\t{\n\t\tA[0]=B[0];\n\t\tA[1]=B[1];\n\t\tA[2]=B[2];\n\t\tA[3]=B[3];\n\t\tA[4]=B[4];\n\t\tA[5]=B[5];\n\t\tA[6]=B[6];\n\t\tA[7]=B[7];\n\t\tA+=8;\n\t\tB+=8;\n\t\t}\n\tswitch (b->top&7)\n\t\t{\n\tcase 7:\n\t\tA[6]=B[6];\n\tcase 6:\n\t\tA[5]=B[5];\n\tcase 5:\n\t\tA[4]=B[4];\n\tcase 4:\n\t\tA[3]=B[3];\n\tcase 3:\n\t\tA[2]=B[2];\n\tcase 2:\n\t\tA[1]=B[1];\n\tcase 1:\n\t\tA[0]=B[0];\n        case 0:\n\t\t;\n\t\t}\n#else\n\tmemcpy(a->d,b->d,sizeof(b->d[0])*b->top);\n#endif\n\ta->top=b->top;\n\tif ((a->top == 0) && (a->d != NULL))\n\t\ta->d[0]=0;\n\ta->neg=b->neg;\n\treturn(a);\n\t}', 'BIGNUM *bn_expand2(BIGNUM *b, int words)\n\t{\n\tBN_ULONG *A,*B,*a;\n\tint i,j;\n\tbn_check_top(b);\n\tif (words > b->max)\n\t\t{\n\t\tbn_check_top(b);\n\t\tif (BN_get_flags(b,BN_FLG_STATIC_DATA))\n\t\t\t{\n\t\t\tBNerr(BN_F_BN_EXPAND2,BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);\n\t\t\treturn(NULL);\n\t\t\t}\n\t\ta=A=(BN_ULONG *)Malloc(sizeof(BN_ULONG)*(words+1));\n\t\tif (A == NULL)\n\t\t\t{\n\t\t\tBNerr(BN_F_BN_EXPAND2,ERR_R_MALLOC_FAILURE);\n\t\t\treturn(NULL);\n\t\t\t}\nmemset(A,0x5c,sizeof(BN_ULONG)*(words+1));\n#if 1\n\t\tB=b->d;\n\t\tif (B != NULL)\n\t\t\t{\n\t\t\tfor (i=b->top&(~7); i>0; i-=8)\n\t\t\t\t{\n\t\t\t\tA[0]=B[0]; A[1]=B[1]; A[2]=B[2]; A[3]=B[3];\n\t\t\t\tA[4]=B[4]; A[5]=B[5]; A[6]=B[6]; A[7]=B[7];\n\t\t\t\tA+=8;\n\t\t\t\tB+=8;\n\t\t\t\t}\n\t\t\tswitch (b->top&7)\n\t\t\t\t{\n\t\t\tcase 7:\n\t\t\t\tA[6]=B[6];\n\t\t\tcase 6:\n\t\t\t\tA[5]=B[5];\n\t\t\tcase 5:\n\t\t\t\tA[4]=B[4];\n\t\t\tcase 4:\n\t\t\t\tA[3]=B[3];\n\t\t\tcase 3:\n\t\t\t\tA[2]=B[2];\n\t\t\tcase 2:\n\t\t\t\tA[1]=B[1];\n\t\t\tcase 1:\n\t\t\t\tA[0]=B[0];\n\t\t\tcase 0:\n\t\t\t\t;\n\t\t\t\t}\n\t\t\tFree(b->d);\n\t\t\t}\n\t\tb->d=a;\n\t\tb->max=words;\n\t\tB= &(b->d[b->top]);\n\t\tj=(b->max - b->top) & ~7;\n\t\tfor (i=0; i<j; i+=8)\n\t\t\t{\n\t\t\tB[0]=0; B[1]=0; B[2]=0; B[3]=0;\n\t\t\tB[4]=0; B[5]=0; B[6]=0; B[7]=0;\n\t\t\tB+=8;\n\t\t\t}\n\t\tj=(b->max - b->top) & 7;\n\t\tfor (i=0; i<j; i++)\n\t\t\t{\n\t\t\tB[0]=0;\n\t\t\tB++;\n\t\t\t}\n#else\n\t\t\tmemcpy(a->d,b->d,sizeof(b->d[0])*b->top);\n#endif\n\t\t}\n\treturn(b);\n\t}']