crypto/bn/bntest.c:807: error: BUFFER_OVERRUN_L3
  Offset: [7, +oo] (⇐ [0, +oo] + 7) Size: [0, +oo] by call to `BN_rshift`.
Showing all 11 steps of the trace


crypto/bn/bntest.c:801:2: Call
799.   	b=BN_new();
800.   	c=BN_new();
801.   	BN_one(c);
        ^
802.   
803.   	BN_rand(a,200,0,0); /**/

crypto/bn/bn_lib.c:548:1: Parameter `*a->d`
  546.   	}
  547.   
  548. > int BN_set_word(BIGNUM *a, BN_ULONG w)
  549.   	{
  550.   	int i,n;

crypto/bn/bntest.c:803:2: Call
801.   	BN_one(c);
802.   
803.   	BN_rand(a,200,0,0); /**/
        ^
804.   	a->neg=rand_neg();
805.   	for (i=0; i<70; i++)

crypto/bn/bn_rand.c:65:1: Parameter `*rnd->d`
  63.   #include "rand.h"
  64.   
  65. > int BN_rand(BIGNUM *rnd, int bits, int top, int bottom)
  66.   	{
  67.   	unsigned char *buf=NULL;

crypto/bn/bntest.c:807:3: Call
805.   	for (i=0; i<70; i++)
806.   		{
807.   		BN_rshift(b,a,i+1);
         ^
808.   		BN_add(c,c,c);
809.   		if (bp != NULL)

crypto/bn/bn_shift.c:156:1: Parameter `*r->d`
  154.   	}
  155.   
  156. > int BN_rshift(BIGNUM *r, BIGNUM *a, int n)
  157.   	{
  158.   	int i,j,nw,lb,rb;

crypto/bn/bn_shift.c:173:7: Call
  171.   		{
  172.   		r->neg=a->neg;
  173.   		if (bn_wexpand(r,a->top-nw+1) == NULL) return(0);
               ^
  174.   		}
  175.   

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_rshift` 
    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);
	}
['int test_rshift(BIO *bp)\n\t{\n\tBIGNUM *a,*b,*c;\n\tint i;\n\ta=BN_new();\n\tb=BN_new();\n\tc=BN_new();\n\tBN_one(c);\n\tBN_rand(a,200,0,0);\n\ta->neg=rand_neg();\n\tfor (i=0; i<70; i++)\n\t\t{\n\t\tBN_rshift(b,a,i+1);\n\t\tBN_add(c,c,c);\n\t\tif (bp != NULL)\n\t\t\t{\n\t\t\tif (!results)\n\t\t\t\t{\n\t\t\t\tBN_print(bp,a);\n\t\t\t\tBIO_puts(bp," / ");\n\t\t\t\tBN_print(bp,c);\n\t\t\t\tBIO_puts(bp," - ");\n\t\t\t\t}\n\t\t\tBN_print(bp,b);\n\t\t\tBIO_puts(bp,"\\n");\n\t\t\t}\n\t\t}\n\tBN_free(a);\n\tBN_free(b);\n\tBN_free(c);\n\treturn(1);\n\t}', 'int BN_set_word(BIGNUM *a, BN_ULONG w)\n\t{\n\tint i,n;\n\tif (bn_expand(a,sizeof(BN_ULONG)*8) == NULL) return(0);\n\tn=sizeof(BN_ULONG)/BN_BYTES;\n\ta->neg=0;\n\ta->top=0;\n\ta->d[0]=(BN_ULONG)w&BN_MASK2;\n\tif (a->d[0] != 0) a->top=1;\n\tfor (i=1; i<n; i++)\n\t\t{\n#ifndef SIXTY_FOUR_BIT\n\t\tw>>=BN_BITS4;\n\t\tw>>=BN_BITS4;\n#endif\n\t\ta->d[i]=(BN_ULONG)w&BN_MASK2;\n\t\tif (a->d[i] != 0) a->top=i+1;\n\t\t}\n\treturn(1);\n\t}', 'int BN_rand(BIGNUM *rnd, int bits, int top, int bottom)\n\t{\n\tunsigned char *buf=NULL;\n\tint ret=0,bit,bytes,mask;\n\ttime_t tim;\n\tbytes=(bits+7)/8;\n\tbit=(bits-1)%8;\n\tmask=0xff<<bit;\n\tbuf=(unsigned char *)Malloc(bytes);\n\tif (buf == NULL)\n\t\t{\n\t\tBNerr(BN_F_BN_RAND,ERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t\t}\n\ttime(&tim);\n\tRAND_seed(&tim,sizeof(tim));\n\tRAND_bytes(buf,(int)bytes);\n\tif (top)\n\t\t{\n\t\tif (bit == 0)\n\t\t\t{\n\t\t\tbuf[0]=1;\n\t\t\tbuf[1]|=0x80;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tbuf[0]|=(3<<(bit-1));\n\t\t\tbuf[0]&= ~(mask<<1);\n\t\t\t}\n\t\t}\n\telse\n\t\t{\n\t\tbuf[0]|=(1<<bit);\n\t\tbuf[0]&= ~(mask<<1);\n\t\t}\n\tif (bottom)\n\t\tbuf[bytes-1]|=1;\n\tif (!BN_bin2bn(buf,bytes,rnd)) goto err;\n\tret=1;\nerr:\n\tif (buf != NULL)\n\t\t{\n\t\tmemset(buf,0,bytes);\n\t\tFree(buf);\n\t\t}\n\treturn(ret);\n\t}', 'int BN_rshift(BIGNUM *r, BIGNUM *a, int n)\n\t{\n\tint i,j,nw,lb,rb;\n\tBN_ULONG *t,*f;\n\tBN_ULONG l,tmp;\n\tnw=n/BN_BITS2;\n\trb=n%BN_BITS2;\n\tlb=BN_BITS2-rb;\n\tif (nw > a->top)\n\t\t{\n\t\tBN_zero(r);\n\t\treturn(1);\n\t\t}\n\tif (r != a)\n\t\t{\n\t\tr->neg=a->neg;\n\t\tif (bn_wexpand(r,a->top-nw+1) == NULL) return(0);\n\t\t}\n\tf= &(a->d[nw]);\n\tt=r->d;\n\tj=a->top-nw;\n\tr->top=j;\n\tif (rb == 0)\n\t\t{\n\t\tfor (i=j+1; i > 0; i--)\n\t\t\t*(t++)= *(f++);\n\t\t}\n\telse\n\t\t{\n\t\tl= *(f++);\n\t\tfor (i=1; i<j; i++)\n\t\t\t{\n\t\t\ttmp =(l>>rb)&BN_MASK2;\n\t\t\tl= *(f++);\n\t\t\t*(t++) =(tmp|(l<<lb))&BN_MASK2;\n\t\t\t}\n\t\t*(t++) =(l>>rb)&BN_MASK2;\n\t\t}\n\t*t=0;\n\tbn_fix_top(r);\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}']