crypto/bn/bntest.c:429: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned64 by call to `BN_lshift`.
Showing all 9 steps of the trace


crypto/bn/bntest.c:427:4: Call
425.   		if (i < num1)
426.   			{
427.   			BN_bntest_rand(&a,400,0,0);
          ^
428.   			BN_copy(&b,&a);
429.   			BN_lshift(&a,&a,i);

crypto/bn/bn_rand.c:224:9: Call
  222.   int     BN_bntest_rand(BIGNUM *rnd, size_t bits, int top, int bottom)
  223.   	{
  224.   	return bnrand(2, rnd, bits, top, bottom);
                 ^
  225.   	}
  226.   #endif

crypto/bn/bn_rand.c:118:1: Parameter `rnd->top`
    116.   #include <openssl/rand.h>
    117.   
    118. > static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
    119.   	{
    120.   	unsigned char *buf=NULL;

crypto/bn/bntest.c:428:4: Call
426.   			{
427.   			BN_bntest_rand(&a,400,0,0);
428.   			BN_copy(&b,&a);
          ^
429.   			BN_lshift(&a,&a,i);
430.   			BN_add_word(&a,i);

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

crypto/bn/bntest.c:429:4: Call
427.   			BN_bntest_rand(&a,400,0,0);
428.   			BN_copy(&b,&a);
429.   			BN_lshift(&a,&a,i);
          ^
430.   			BN_add_word(&a,i);
431.   			}

crypto/bn/bn_shift.c:132:1: <LHS trace>
130.   	}
131.   
132. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
133.   	{
134.   	int i,nw,lb,rb;

crypto/bn/bn_shift.c:132:1: Parameter `a->top`
  130.   	}
  131.   
  132. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
  133.   	{
  134.   	int i,nw,lb,rb;

crypto/bn/bn_shift.c:150:8: Binary operation: ([0, +oo] - 1):unsigned64 by call to `BN_lshift` 
  148.   	t[a->top+nw]=0;
  149.   	if (lb == 0)
  150.   		for (i=a->top-1; i>=0; i--)
                ^
  151.   			t[nw+i]=f[i];
  152.   	else

int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
	{
	int i,nw,lb,rb;
	BN_ULONG *t,*f;
	BN_ULONG l;
	bn_check_top(r);
	bn_check_top(a);
	r->neg=a->neg;
	nw=n/BN_BITS2;
	if (bn_wexpand(r,a->top+nw+1) == NULL) return(0);
	lb=n%BN_BITS2;
	rb=BN_BITS2-lb;
	f=a->d;
	t=r->d;
	t[a->top+nw]=0;
	if (lb == 0)
		for (i=a->top-1; i>=0; i--)
			t[nw+i]=f[i];
	else
		for (i=a->top-1; i>=0; i--)
			{
			l=f[i];
			t[nw+i+1]|=(l>>rb)&BN_MASK2;
			t[nw+i]=(l<<lb)&BN_MASK2;
			}
	memset(t,0,nw*sizeof(t[0]));
	r->top=a->top+nw+1;
	bn_correct_top(r);
	bn_check_top(r);
	return(1);
	}
['int test_div(BIO *bp, BN_CTX *ctx)\n\t{\n\tBIGNUM a,b,c,d,e;\n\tint i;\n\tBN_init(&a);\n\tBN_init(&b);\n\tBN_init(&c);\n\tBN_init(&d);\n\tBN_init(&e);\n\tfor (i=0; i<num0+num1; i++)\n\t\t{\n\t\tif (i < num1)\n\t\t\t{\n\t\t\tBN_bntest_rand(&a,400,0,0);\n\t\t\tBN_copy(&b,&a);\n\t\t\tBN_lshift(&a,&a,i);\n\t\t\tBN_add_word(&a,i);\n\t\t\t}\n\t\telse\n\t\t\tBN_bntest_rand(&b,50+3*(i-num1),0,0);\n\t\ta.neg=rand_neg();\n\t\tb.neg=rand_neg();\n\t\tBN_div(&d,&c,&a,&b,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,&b);\n\t\t\t\tBIO_puts(bp," - ");\n\t\t\t\t}\n\t\t\tBN_print(bp,&d);\n\t\t\tBIO_puts(bp,"\\n");\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,&b);\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\tBN_mul(&e,&d,&b,ctx);\n\t\tBN_add(&d,&e,&c);\n\t\tBN_sub(&d,&d,&a);\n\t\tif(!BN_is_zero(&d))\n\t\t    {\n\t\t    fprintf(stderr,"Division test failed!\\n");\n\t\t    return 0;\n\t\t    }\n\t\t}\n\tBN_free(&a);\n\tBN_free(&b);\n\tBN_free(&c);\n\tBN_free(&d);\n\tBN_free(&e);\n\treturn(1);\n\t}', 'int     BN_bntest_rand(BIGNUM *rnd, size_t bits, int top, int bottom)\n\t{\n\treturn bnrand(2, rnd, bits, top, bottom);\n\t}', 'static int bnrand(int pseudorand, 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\tif (bits == 0)\n\t\t{\n\t\tBN_zero(rnd);\n\t\treturn 1;\n\t\t}\n\tbytes=(bits+7)/8;\n\tbit=(bits-1)%8;\n\tmask=0xff<<(bit+1);\n\tbuf=(unsigned char *)OPENSSL_malloc(bytes);\n\tif (buf == NULL)\n\t\t{\n\t\tBNerr(BN_F_BNRAND,ERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t\t}\n\ttime(&tim);\n\tRAND_add(&tim,sizeof(tim),0.0);\n\tif (pseudorand)\n\t\t{\n\t\tif (RAND_pseudo_bytes(buf, bytes) == -1)\n\t\t\tgoto err;\n\t\t}\n\telse\n\t\t{\n\t\tif (RAND_bytes(buf, bytes) <= 0)\n\t\t\tgoto err;\n\t\t}\n#if 1\n\tif (pseudorand == 2)\n\t\t{\n\t\tint i;\n\t\tunsigned char c;\n\t\tfor (i = 0; i < bytes; i++)\n\t\t\t{\n\t\t\tRAND_pseudo_bytes(&c, 1);\n\t\t\tif (c >= 128 && i > 0)\n\t\t\t\tbuf[i] = buf[i-1];\n\t\t\telse if (c < 42)\n\t\t\t\tbuf[i] = 0;\n\t\t\telse if (c < 84)\n\t\t\t\tbuf[i] = 255;\n\t\t\t}\n\t\t}\n#endif\n\tif (top != -1)\n\t\t{\n\t\tif (top)\n\t\t\t{\n\t\t\tif (bit == 0)\n\t\t\t\t{\n\t\t\t\tbuf[0]=1;\n\t\t\t\tbuf[1]|=0x80;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tbuf[0]|=(3<<(bit-1));\n\t\t\t\t}\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tbuf[0]|=(1<<bit);\n\t\t\t}\n\t\t}\n\tbuf[0] &= ~mask;\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\tOPENSSL_cleanse(buf,bytes);\n\t\tOPENSSL_free(buf);\n\t\t}\n\tbn_check_top(rnd);\n\treturn(ret);\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\ta->neg=b->neg;\n\tbn_check_top(a);\n\treturn(a);\n\t}', 'int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)\n\t{\n\tint i,nw,lb,rb;\n\tBN_ULONG *t,*f;\n\tBN_ULONG l;\n\tbn_check_top(r);\n\tbn_check_top(a);\n\tr->neg=a->neg;\n\tnw=n/BN_BITS2;\n\tif (bn_wexpand(r,a->top+nw+1) == NULL) return(0);\n\tlb=n%BN_BITS2;\n\trb=BN_BITS2-lb;\n\tf=a->d;\n\tt=r->d;\n\tt[a->top+nw]=0;\n\tif (lb == 0)\n\t\tfor (i=a->top-1; i>=0; i--)\n\t\t\tt[nw+i]=f[i];\n\telse\n\t\tfor (i=a->top-1; i>=0; i--)\n\t\t\t{\n\t\t\tl=f[i];\n\t\t\tt[nw+i+1]|=(l>>rb)&BN_MASK2;\n\t\t\tt[nw+i]=(l<<lb)&BN_MASK2;\n\t\t\t}\n\tmemset(t,0,nw*sizeof(t[0]));\n\tr->top=a->top+nw+1;\n\tbn_correct_top(r);\n\tbn_check_top(r);\n\treturn(1);\n\t}']