crypto/bn/bn_prime.c:234: error: BUFFER_OVERRUN_L1
  Offset: [7, +oo] (⇐ [0, +oo] + 7) Size: [0, 4] by call to `BN_mod_mul_montgomery`.
Showing all 12 steps of the trace


crypto/bn/bn_prime.c:234:7: Call
232.   	k=BN_num_bits(n1);
233.   
234.   	if (!BN_to_montgomery(mont_one,BN_value_one(),mont,ctx2)) goto err;
             ^
235.   	if (!BN_to_montgomery(mont_n1,n1,mont,ctx2)) goto err;
236.   	if (!BN_to_montgomery(mont_a,a,mont,ctx2)) goto err;

crypto/bn/bn_lib.c:127:26: Assignment
  125.   	{
  126.   	static BN_ULONG data_one=1L;
  127.   	static BIGNUM const_one={&data_one,1,1,0};
                                  ^
  128.   
  129.   	return(&const_one);

crypto/bn/bn_prime.c:234:7: Call
232.   	k=BN_num_bits(n1);
233.   
234.   	if (!BN_to_montgomery(mont_one,BN_value_one(),mont,ctx2)) goto err;
             ^
235.   	if (!BN_to_montgomery(mont_n1,n1,mont,ctx2)) goto err;
236.   	if (!BN_to_montgomery(mont_a,a,mont,ctx2)) goto err;

crypto/bn/bn_mont.c:71:1: Parameter `a->top`
  69.   #define MONT_WORD
  70.   
  71. > int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_MONT_CTX *mont,
  72.   	     BN_CTX *ctx)
  73.   	{

crypto/bn/bn_mont.c:93:8: Call
  91.   			tmp->top--;
  92.   #else
  93.   		if (!BN_sqr(tmp,a,ctx)) goto err;
               ^
  94.   #endif
  95.   		}

crypto/bn/bn_sqr.c:65:1: Parameter `r->max`
    63.   /* r must not be a */
    64.   /* I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96 */
    65. > int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx)
    66.   	{
    67.   	int max,al;

crypto/bn/bn_sqr.c:85:6: Call
    83.   
    84.   	max=(al+al);
    85.   	if (bn_wexpand(rr,max+1) == NULL) return(0);
               ^
    86.   
    87.   	r->neg=0;

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 `words`
      342.   	}
      343.   
      344. > BIGNUM *bn_expand2(BIGNUM *b, int words)
      345.   	{
      346.   	BN_ULONG *A,*B,*a;

crypto/bn/bn_lib.c:359:19: Array declaration
      357.   			return(NULL);
      358.   			}
      359.   		a=A=(BN_ULONG *)Malloc(sizeof(BN_ULONG)*(words+1));
                               ^
      360.   		if (A == NULL)
      361.   			{

crypto/bn/bn_lib.c:359:5: Assignment
      357.   			return(NULL);
      358.   			}
      359.   		a=A=(BN_ULONG *)Malloc(sizeof(BN_ULONG)*(words+1));
                 ^
      360.   		if (A == NULL)
      361.   			{

crypto/bn/bn_lib.c:377:38: Array access: Offset: [7, +oo] (⇐ [0, +oo] + 7) Size: [0, 4] by call to `BN_mod_mul_montgomery` 
      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 witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx, BN_CTX *ctx2,\n\t     BN_MONT_CTX *mont)\n\t{\n\tint k,i,ret= -1,good;\n\tBIGNUM *d,*dd,*tmp,*d1,*d2,*n1;\n\tBIGNUM *mont_one,*mont_n1,*mont_a;\n\td1= &(ctx->bn[ctx->tos]);\n\td2= &(ctx->bn[ctx->tos+1]);\n\tn1= &(ctx->bn[ctx->tos+2]);\n\tctx->tos+=3;\n\tmont_one= &(ctx2->bn[ctx2->tos]);\n\tmont_n1= &(ctx2->bn[ctx2->tos+1]);\n\tmont_a= &(ctx2->bn[ctx2->tos+2]);\n\tctx2->tos+=3;\n\td=d1;\n\tdd=d2;\n\tif (!BN_one(d)) goto err;\n\tif (!BN_sub(n1,n,d)) goto err;\n\tk=BN_num_bits(n1);\n\tif (!BN_to_montgomery(mont_one,BN_value_one(),mont,ctx2)) goto err;\n\tif (!BN_to_montgomery(mont_n1,n1,mont,ctx2)) goto err;\n\tif (!BN_to_montgomery(mont_a,a,mont,ctx2)) goto err;\n\tBN_copy(d,mont_one);\n\tfor (i=k-1; i>=0; i--)\n\t\t{\n\t\tif (\t(BN_cmp(d,mont_one) != 0) &&\n\t\t\t(BN_cmp(d,mont_n1) != 0))\n\t\t\tgood=1;\n\t\telse\n\t\t\tgood=0;\n\t\tBN_mod_mul_montgomery(dd,d,d,mont,ctx2);\n\t\tif (good && (BN_cmp(dd,mont_one) == 0))\n\t\t\t{\n\t\t\tret=1;\n\t\t\tgoto err;\n\t\t\t}\n\t\tif (BN_is_bit_set(n1,i))\n\t\t\t{\n\t\t\tBN_mod_mul_montgomery(d,dd,mont_a,mont,ctx2);\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\ttmp=d;\n\t\t\td=dd;\n\t\t\tdd=tmp;\n\t\t\t}\n\t\t}\n\tif (BN_cmp(d,mont_one) == 0)\n\t\ti=0;\n\telse\ti=1;\n\tret=i;\nerr:\n\tctx->tos-=3;\n\tctx2->tos-=3;\n\treturn(ret);\n\t}', 'BIGNUM *BN_value_one(void)\n\t{\n\tstatic BN_ULONG data_one=1L;\n\tstatic BIGNUM const_one={&data_one,1,1,0};\n\treturn(&const_one);\n\t}', 'int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_MONT_CTX *mont,\n\t     BN_CTX *ctx)\n\t{\n\tBIGNUM *tmp,*tmp2;\n        tmp= &(ctx->bn[ctx->tos]);\n        tmp2= &(ctx->bn[ctx->tos]);\n\tctx->tos+=2;\n\tbn_check_top(tmp);\n\tbn_check_top(tmp2);\n\tif (a == b)\n\t\t{\n#if 0\n\t\tbn_wexpand(tmp,a->top*2);\n\t\tbn_wexpand(tmp2,a->top*4);\n\t\tbn_sqr_recursive(tmp->d,a->d,a->top,tmp2->d);\n\t\ttmp->top=a->top*2;\n\t\tif (tmp->d[tmp->top-1] == 0)\n\t\t\ttmp->top--;\n#else\n\t\tif (!BN_sqr(tmp,a,ctx)) goto err;\n#endif\n\t\t}\n\telse\n\t\t{\n\t\tif (!BN_mul(tmp,a,b,ctx)) goto err;\n\t\t}\n\tif (!BN_from_montgomery(r,tmp,mont,ctx)) goto err;\n\tctx->tos-=2;\n\treturn(1);\nerr:\n\treturn(0);\n\t}', 'int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx)\n\t{\n\tint max,al;\n\tBIGNUM *tmp,*rr;\n#ifdef BN_COUNT\nprintf("BN_sqr %d * %d\\n",a->top,a->top);\n#endif\n\tbn_check_top(a);\n\ttmp= &(ctx->bn[ctx->tos]);\n\trr=(a != r)?r: (&ctx->bn[ctx->tos+1]);\n\tal=a->top;\n\tif (al <= 0)\n\t\t{\n\t\tr->top=0;\n\t\treturn(1);\n\t\t}\n\tmax=(al+al);\n\tif (bn_wexpand(rr,max+1) == NULL) return(0);\n\tr->neg=0;\n\tif (al == 4)\n\t\t{\n#ifndef BN_SQR_COMBA\n\t\tBN_ULONG t[8];\n\t\tbn_sqr_normal(rr->d,a->d,4,t);\n#else\n\t\tbn_sqr_comba4(rr->d,a->d);\n#endif\n\t\t}\n\telse if (al == 8)\n\t\t{\n#ifndef BN_SQR_COMBA\n\t\tBN_ULONG t[16];\n\t\tbn_sqr_normal(rr->d,a->d,8,t);\n#else\n\t\tbn_sqr_comba8(rr->d,a->d);\n#endif\n\t\t}\n\telse\n\t\t{\n#if defined(BN_RECURSION)\n\t\tif (al < BN_SQR_RECURSIVE_SIZE_NORMAL)\n\t\t\t{\n\t\t\tBN_ULONG t[BN_SQR_RECURSIVE_SIZE_NORMAL*2];\n\t\t\tbn_sqr_normal(rr->d,a->d,al,t);\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tint j,k;\n\t\t\tj=BN_num_bits_word((BN_ULONG)al);\n\t\t\tj=1<<(j-1);\n\t\t\tk=j+j;\n\t\t\tif (al == j)\n\t\t\t\t{\n\t\t\t\tif (bn_wexpand(a,k*2) == NULL) return(0);\n\t\t\t\tif (bn_wexpand(tmp,k*2) == NULL) return(0);\n\t\t\t\tbn_sqr_recursive(rr->d,a->d,al,tmp->d);\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tif (bn_wexpand(tmp,max) == NULL) return(0);\n\t\t\t\tbn_sqr_normal(rr->d,a->d,al,tmp->d);\n\t\t\t\t}\n\t\t\t}\n#else\n\t\tif (bn_wexpand(tmp,max) == NULL) return(0);\n\t\tbn_sqr_normal(rr->d,a->d,al,tmp->d);\n#endif\n\t\t}\n\trr->top=max;\n\tif ((max > 0) && (rr->d[max-1] == 0)) rr->top--;\n\tif (rr != r) BN_copy(r,rr);\n\treturn(1);\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}']