crypto/bn/bn_print.c:186: error: BUFFER_OVERRUN_L3
  Offset: [3, +oo] (⇐ [0, +oo] + 3) Size: [2, +oo] by call to `bn_expand2`.
Showing all 7 steps of the trace


crypto/bn/bn_print.c:168:7: Assignment
166.   	if (*a == '-') { neg=1; a++; }
167.   
168.   	for (i=0; isxdigit((unsigned char) a[i]); i++)
             ^
169.   		;
170.   

crypto/bn/bn_print.c:186:6: Call
184.   
185.   	/* i is the number of hex digests; */
186.   	if (bn_expand(ret,i*4) == NULL) goto err;
            ^
187.   
188.   	j=i; /* least significate 'hex' */

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:448:32: Array access: Offset: [3, +oo] (⇐ [0, +oo] + 3) Size: [2, +oo] by call to `bn_expand2` 
  446.   				BN_ULONG a0,a1,a2,a3;
  447.   				a0=B[0]; a1=B[1]; a2=B[2]; a3=B[3];
  448.   				A[0]=a0; A[1]=a1; A[2]=a2; A[3]=a3;
                                        ^
  449.   				}
  450.   			switch (b->top&3)

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 BN_hex2bn(BIGNUM **bn, char *a)\n\t{\n\tBIGNUM *ret=NULL;\n\tBN_ULONG l=0;\n\tint neg=0,h,m,i,j,k,c;\n\tint num;\n\tif ((a == NULL) || (*a == '\\0')) return(0);\n\tif (*a == '-') { neg=1; a++; }\n\tfor (i=0; isxdigit((unsigned char) a[i]); i++)\n\t\t;\n\tnum=i+neg;\n\tif (bn == NULL) return(num);\n\tif (*bn == NULL)\n\t\t{\n\t\tif ((ret=BN_new()) == NULL) return(0);\n\t\t}\n\telse\n\t\t{\n\t\tret= *bn;\n\t\tBN_zero(ret);\n\t\t}\n\tif (bn_expand(ret,i*4) == NULL) goto err;\n\tj=i;\n\tm=0;\n\th=0;\n\twhile (j > 0)\n\t\t{\n\t\tm=((BN_BYTES*2) <= j)?(BN_BYTES*2):j;\n\t\tl=0;\n\t\tfor (;;)\n\t\t\t{\n\t\t\tc=a[j-m];\n\t\t\tif ((c >= '0') && (c <= '9')) k=c-'0';\n\t\t\telse if ((c >= 'a') && (c <= 'f')) k=c-'a'+10;\n\t\t\telse if ((c >= 'A') && (c <= 'F')) k=c-'A'+10;\n\t\t\telse k=0;\n\t\t\tl=(l<<4)|k;\n\t\t\tif (--m <= 0)\n\t\t\t\t{\n\t\t\t\tret->d[h++]=l;\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\tj-=(BN_BYTES*2);\n\t\t}\n\tret->top=h;\n\tbn_fix_top(ret);\n\tret->neg=neg;\n\t*bn=ret;\n\treturn(num);\nerr:\n\tif (*bn == NULL) BN_free(ret);\n\treturn(0);\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}']