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


crypto/bn/bntest.c:770:2: Call
768.   	b=BN_new();
769.   
770.   	BN_rand(a,200,0,0); /**/
        ^
771.   	a->neg=rand_neg();
772.   	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:774:3: Call
772.   	for (i=0; i<70; i++)
773.   		{
774.   		BN_lshift1(b,a);
         ^
775.   		if (bp != NULL)
776.   			{

crypto/bn/bn_shift.c:63:1: Parameter `*r->d`
  61.   #include "bn_lcl.h"
  62.   
  63. > int BN_lshift1(BIGNUM *r, BIGNUM *a)
  64.   	{
  65.   	register BN_ULONG *ap,*rp,t,c;

crypto/bn/bn_shift.c:71:7: Call
  69.   		{
  70.   		r->neg=a->neg;
  71.   		if (bn_wexpand(r,a->top+1) == NULL) return(0);
              ^
  72.   		r->top=a->top;
  73.   		}

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_lshift1` 
    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_lshift1(BIO *bp)\n\t{\n\tBIGNUM *a,*b;\n\tint i;\n\ta=BN_new();\n\tb=BN_new();\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_lshift1(b,a);\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," * 2");\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\tBN_copy(a,b);\n\t\t}\n\tBN_free(a);\n\tBN_free(b);\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_lshift1(BIGNUM *r, BIGNUM *a)\n\t{\n\tregister BN_ULONG *ap,*rp,t,c;\n\tint i;\n\tif (r != a)\n\t\t{\n\t\tr->neg=a->neg;\n\t\tif (bn_wexpand(r,a->top+1) == NULL) return(0);\n\t\tr->top=a->top;\n\t\t}\n\telse\n\t\t{\n\t\tif (bn_wexpand(r,a->top+1) == NULL) return(0);\n\t\t}\n\tap=a->d;\n\trp=r->d;\n\tc=0;\n\tfor (i=0; i<a->top; i++)\n\t\t{\n\t\tt= *(ap++);\n\t\t*(rp++)=((t<<1)|c)&BN_MASK2;\n\t\tc=(t & BN_TBIT)?1:0;\n\t\t}\n\tif (c)\n\t\t{\n\t\t*rp=1;\n\t\tr->top++;\n\t\t}\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}']