crypto/bn/bntest.c:454: error: BUFFER_OVERRUN_L3
  Offset: [3, +oo] (⇐ [0, +oo] + 3) Size: [0, +oo] by call to `BN_sqr`.
Showing all 12 steps of the trace


crypto/bn/bntest.c:450:3: Call
448.   	for (i=0; i<40; i++)
449.   		{
450.   		BN_rand(&a,40+i*10,0,0);
         ^
451.   		a.neg=rand_neg();
452.   		if (bp == NULL)

crypto/bn/bn_rand.c:65:1: Parameter `*rnd->d`
  63.   #include <openssl/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:454:5: Call
452.   		if (bp == NULL)
453.   			for (j=0; j<100; j++)
454.   				BN_sqr(&c,&a,ctx);
           ^
455.   		BN_sqr(&c,&a,ctx);
456.   		if (bp != NULL)

crypto/bn/bn_sqr.c:65:1: Parameter `*a->d`
  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/bntest.c:454:5: Call
452.   		if (bp == NULL)
453.   			for (j=0; j<100; j++)
454.   				BN_sqr(&c,&a,ctx);
           ^
455.   		BN_sqr(&c,&a,ctx);
456.   		if (bp != NULL)

crypto/bn/bn_sqr.c:65:1: Parameter `*a->d`
  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:130:5: Call
  128.   				{
  129.   				if (bn_wexpand(tmp,max) == NULL) return(0);
  130.   				bn_sqr_normal(rr->d,a->d,al,tmp->d);
             ^
  131.   				}
  132.   			}

crypto/bn/bn_sqr.c:146:1: Parameter `*a`
    144.   
    145.   /* tmp must have 2*n words */
    146. > void bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp)
    147.   	{
    148.   	int i,j,max;

crypto/bn/bn_sqr.c:177:2: Call
    175.   	/* There will not be a carry */
    176.   
    177.   	bn_sqr_words(tmp,a,n);
            ^
    178.   
    179.   	bn_add_words(r,r,tmp,max);

crypto/bn/bn_asm.c:197:1: <Length trace>
195.   	} 
196.   
197. > void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n)
198.           {
199.   	bn_check_num(n);

crypto/bn/bn_asm.c:197:1: Parameter `*a`
      195.   	} 
      196.   
      197. > void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n)
      198.           {
      199.   	bn_check_num(n);

crypto/bn/bn_asm.c:212:3: Array access: Offset: [3, +oo] (⇐ [0, +oo] + 3) Size: [0, +oo] by call to `BN_sqr` 
      210.   		if (--n == 0) break;
      211.   
      212.   		sqr64(r[6],r[7],a[3]);
               ^
      213.   		if (--n == 0) break;
      214.   

void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n)
        {
	bn_check_num(n);
	if (n <= 0) return;
	for (;;)
		{
		sqr64(r[0],r[1],a[0]);
		if (--n == 0) break;
		sqr64(r[2],r[3],a[1]);
		if (--n == 0) break;
		sqr64(r[4],r[5],a[2]);
		if (--n == 0) break;
		sqr64(r[6],r[7],a[3]);
		if (--n == 0) break;
		a+=4;
		r+=8;
		}
	}
['int test_sqr(BIO *bp, BN_CTX *ctx)\n\t{\n\tBIGNUM a,c;\n\tint i;\n\tint j;\n\tBN_init(&a);\n\tBN_init(&c);\n\tfor (i=0; i<40; i++)\n\t\t{\n\t\tBN_rand(&a,40+i*10,0,0);\n\t\ta.neg=rand_neg();\n\t\tif (bp == NULL)\n\t\t\tfor (j=0; j<100; j++)\n\t\t\t\tBN_sqr(&c,&a,ctx);\n\t\tBN_sqr(&c,&a,ctx);\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,&a);\n\t\t\t\tBIO_puts(bp," - ");\n\t\t\t\t}\n\t\t\tBN_print(bp,&c);\n\t\t\tBIO_puts(bp,"\\n");\n\t\t\t}\n\t\t}\n\tBN_free(&a);\n\tBN_free(&c);\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_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}', 'void bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp)\n\t{\n\tint i,j,max;\n\tBN_ULONG *ap,*rp;\n\tmax=n*2;\n\tap=a;\n\trp=r;\n\trp[0]=rp[max-1]=0;\n\trp++;\n\tj=n;\n\tif (--j > 0)\n\t\t{\n\t\tap++;\n\t\trp[j]=bn_mul_words(rp,ap,j,ap[-1]);\n\t\trp+=2;\n\t\t}\n\tfor (i=n-2; i>0; i--)\n\t\t{\n\t\tj--;\n\t\tap++;\n\t\trp[j]=bn_mul_add_words(rp,ap,j,ap[-1]);\n\t\trp+=2;\n\t\t}\n\tbn_add_words(r,r,r,max);\n\tbn_sqr_words(tmp,a,n);\n\tbn_add_words(r,r,tmp,max);\n\t}', 'void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n)\n        {\n\tbn_check_num(n);\n\tif (n <= 0) return;\n\tfor (;;)\n\t\t{\n\t\tsqr64(r[0],r[1],a[0]);\n\t\tif (--n == 0) break;\n\t\tsqr64(r[2],r[3],a[1]);\n\t\tif (--n == 0) break;\n\t\tsqr64(r[4],r[5],a[2]);\n\t\tif (--n == 0) break;\n\t\tsqr64(r[6],r[7],a[3]);\n\t\tif (--n == 0) break;\n\t\ta+=4;\n\t\tr+=8;\n\t\t}\n\t}']