crypto/bn/bntest.c:917: error: BUFFER_OVERRUN_L3
  Offset: [0, 1] Size: [1, 2] by call to `BN_copy`.
Showing all 14 steps of the trace


crypto/bn/bntest.c:910:3: Call
908.   			}
909.   		BN_add(c,a,a);
910.   		BN_sub(a,b,c);
         ^
911.   		if(!BN_is_zero(a))
912.   		    {

crypto/bn/bn_add.c:258:1: Parameter `a->top`
  256.   	}
  257.   
  258. > int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
  259.   	{
  260.   	int max;

crypto/bn/bntest.c:917:3: Call
915.   		    }
916.   		
917.   		BN_copy(a,b);
         ^
918.   		}
919.   	BN_free(a);

crypto/bn/bn_lib.c:499:1: Parameter `a->max`
  497.   	}
  498.   
  499. > BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
  500.   	{
  501.   	int i;

crypto/bn/bn_lib.c:508:6: Call
  506.   
  507.   	if (a == b) return(a);
  508.   	if (bn_wexpand(a,b->top) == NULL) return(NULL);
              ^
  509.   
  510.   #if 1

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

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

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

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

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

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

crypto/bn/bn_lib.c:461:3: Assignment
    459.   			}
    460.   
    461.   		b->d=a;
             ^
    462.   		b->max=words;
    463.   

crypto/bn/bn_lib.c:466:3: Array access: Offset: [0, 1] Size: [1, 2] by call to `BN_copy` 
    464.   		/* Now need to zero any data between b->top and b->max */
    465.   
    466.   		A= &(b->d[b->top]);
             ^
    467.   		for (i=(b->max - b->top)>>3; i>0; i--,A+=8)
    468.   			{

BIGNUM *bn_expand2(BIGNUM *b, int words)
	{
	BN_ULONG *A,*a;
	const BN_ULONG *B;
	int i;
	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);
			}
#if 1
		B=b->d;
		if (B != NULL)
			{
#if 0
			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:
				;
				}
#else
			for (i=b->top>>2; i>0; i--,A+=4,B+=4)
				{
				BN_ULONG a0,a1,a2,a3;
				a0=B[0]; a1=B[1]; a2=B[2]; a3=B[3];
				A[0]=a0; A[1]=a1; A[2]=a2; A[3]=a3;
				}
			switch (b->top&3)
				{
				case 3:	A[2]=B[2];
				case 2:	A[1]=B[1];
				case 1:	A[0]=B[0];
				case 0:	;
				}
#endif
			Free(b->d);
			}
		b->d=a;
		b->max=words;
		A= &(b->d[b->top]);
		for (i=(b->max - b->top)>>3; i>0; i--,A+=8)
			{
			A[0]=0; A[1]=0; A[2]=0; A[3]=0;
			A[4]=0; A[5]=0; A[6]=0; A[7]=0;
			}
		for (i=(b->max - b->top)&7; i>0; i--,A++)
			A[0]=0;
#else
			memset(A,0,sizeof(BN_ULONG)*(words+1));
			memcpy(A,b->d,sizeof(b->d[0])*b->top);
			b->d=a;
			b->max=words;
#endif
		}
	return(b);
	}
['int test_lshift1(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_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_add(c,a,a);\n\t\tBN_sub(a,b,c);\n\t\tif(!BN_is_zero(a))\n\t\t    {\n\t\t    BIO_puts(bp,"Left shift one test failed!\\n");\n\t\t    return 0;\n\t\t    }\n\t\tBN_copy(a,b);\n\t\t}\n\tBN_free(a);\n\tBN_free(b);\n\tBN_free(c);\n\treturn(1);\n\t}', 'int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)\n\t{\n\tint max;\n\tint add=0,neg=0;\n\tconst BIGNUM *tmp;\n\tbn_check_top(a);\n\tbn_check_top(b);\n\tif (a->neg)\n\t\t{\n\t\tif (b->neg)\n\t\t\t{ tmp=a; a=b; b=tmp; }\n\t\telse\n\t\t\t{ add=1; neg=1; }\n\t\t}\n\telse\n\t\t{\n\t\tif (b->neg) { add=1; neg=0; }\n\t\t}\n\tif (add)\n\t\t{\n\t\tif (!BN_uadd(r,a,b)) return(0);\n\t\tr->neg=neg;\n\t\treturn(1);\n\t\t}\n\tmax=(a->top > b->top)?a->top:b->top;\n\tif (bn_wexpand(r,max) == NULL) return(0);\n\tif (BN_ucmp(a,b) < 0)\n\t\t{\n\t\tif (!BN_usub(r,b,a)) return(0);\n\t\tr->neg=1;\n\t\t}\n\telse\n\t\t{\n\t\tif (!BN_usub(r,a,b)) return(0);\n\t\tr->neg=0;\n\t\t}\n\treturn(1);\n\t}', 'BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)\n\t{\n\tint i;\n\tBN_ULONG *A;\n\tconst BN_ULONG *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>>2; i>0; i--,A+=4,B+=4)\n\t\t{\n\t\tBN_ULONG a0,a1,a2,a3;\n\t\ta0=B[0]; a1=B[1]; a2=B[2]; a3=B[3];\n\t\tA[0]=a0; A[1]=a1; A[2]=a2; A[3]=a3;\n\t\t}\n\tswitch (b->top&3)\n\t\t{\n\t\tcase 3: A[2]=B[2];\n\t\tcase 2: A[1]=B[1];\n\t\tcase 1: A[0]=B[0];\n\t\tcase 0: ;\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,*a;\n\tconst BN_ULONG *B;\n\tint i;\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}\n#if 1\n\t\tB=b->d;\n\t\tif (B != NULL)\n\t\t\t{\n#if 0\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#else\n\t\t\tfor (i=b->top>>2; i>0; i--,A+=4,B+=4)\n\t\t\t\t{\n\t\t\t\tBN_ULONG a0,a1,a2,a3;\n\t\t\t\ta0=B[0]; a1=B[1]; a2=B[2]; a3=B[3];\n\t\t\t\tA[0]=a0; A[1]=a1; A[2]=a2; A[3]=a3;\n\t\t\t\t}\n\t\t\tswitch (b->top&3)\n\t\t\t\t{\n\t\t\t\tcase 3:\tA[2]=B[2];\n\t\t\t\tcase 2:\tA[1]=B[1];\n\t\t\t\tcase 1:\tA[0]=B[0];\n\t\t\t\tcase 0:\t;\n\t\t\t\t}\n#endif\n\t\t\tFree(b->d);\n\t\t\t}\n\t\tb->d=a;\n\t\tb->max=words;\n\t\tA= &(b->d[b->top]);\n\t\tfor (i=(b->max - b->top)>>3; i>0; i--,A+=8)\n\t\t\t{\n\t\t\tA[0]=0; A[1]=0; A[2]=0; A[3]=0;\n\t\t\tA[4]=0; A[5]=0; A[6]=0; A[7]=0;\n\t\t\t}\n\t\tfor (i=(b->max - b->top)&7; i>0; i--,A++)\n\t\t\tA[0]=0;\n#else\n\t\t\tmemset(A,0,sizeof(BN_ULONG)*(words+1));\n\t\t\tmemcpy(A,b->d,sizeof(b->d[0])*b->top);\n\t\t\tb->d=a;\n\t\t\tb->max=words;\n#endif\n\t\t}\n\treturn(b);\n\t}']