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


crypto/bn/bntest.c:1514:3: Call
1512.   	for (i=0; i<num0; i++)
1513.   		{
1514.   		BN_bntest_rand(a, 512, 0, 0);
          ^
1515.   		for (j=0; j < 2; j++)
1516.   			{

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:1517:4: Call
1515.   		for (j=0; j < 2; j++)
1516.   			{
1517.   			BN_GF2m_mod(c, a, b[j]);
           ^
1518.   			BN_GF2m_mod_sqrt(d, a, b[j], ctx);
1519.   			BN_GF2m_mod_sqr(e, d, b[j], ctx);

crypto/bn/bn_gf2m.c:359:1: Parameter `p->top`
  357.    * BN_GF2m_mod_arr function.
  358.    */
  359. > int	BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p)
  360.   	{
  361.   	int ret = 0;

crypto/bn/bn_gf2m.c:362:18: Call
  360.   	{
  361.   	int ret = 0;
  362.   	const int max = BN_num_bits(p) + 1;
                          ^
  363.   	int *arr=NULL;
  364.   	bn_check_top(a);

crypto/bn/bn_lib.c:248:1: <LHS trace>
246.   	}
247.   
248. > int BN_num_bits(const BIGNUM *a)
249.   	{
250.   	int i = a->top - 1;

crypto/bn/bn_lib.c:248:1: Parameter `a->top`
    246.   	}
    247.   
    248. > int BN_num_bits(const BIGNUM *a)
    249.   	{
    250.   	int i = a->top - 1;

crypto/bn/bn_lib.c:250:2: Binary operation: ([0, +oo] - 1):unsigned64 by call to `BN_GF2m_mod` 
    248.   int BN_num_bits(const BIGNUM *a)
    249.   	{
    250.   	int i = a->top - 1;
            ^
    251.   	bn_check_top(a);
    252.   

int BN_num_bits(const BIGNUM *a)
	{
	int i = a->top - 1;
	bn_check_top(a);
	if (BN_is_zero(a)) return 0;
	return ((i*BN_BITS2) + BN_num_bits_word(a->d[i]));
	}
['int test_gf2m_mod_sqrt(BIO *bp,BN_CTX *ctx)\n\t{\n\tBIGNUM *a,*b[2],*c,*d,*e,*f;\n\tint i, j, ret = 0;\n\tint p0[] = {163,7,6,3,0,-1};\n\tint p1[] = {193,15,0,-1};\n\ta=BN_new();\n\tb[0]=BN_new();\n\tb[1]=BN_new();\n\tc=BN_new();\n\td=BN_new();\n\te=BN_new();\n\tf=BN_new();\n\tBN_GF2m_arr2poly(p0, b[0]);\n\tBN_GF2m_arr2poly(p1, b[1]);\n\tfor (i=0; i<num0; i++)\n\t\t{\n\t\tBN_bntest_rand(a, 512, 0, 0);\n\t\tfor (j=0; j < 2; j++)\n\t\t\t{\n\t\t\tBN_GF2m_mod(c, a, b[j]);\n\t\t\tBN_GF2m_mod_sqrt(d, a, b[j], ctx);\n\t\t\tBN_GF2m_mod_sqr(e, d, b[j], ctx);\n#if 0\n\t\t\tif (bp != NULL)\n\t\t\t\t{\n\t\t\t\tif (!results)\n\t\t\t\t\t{\n\t\t\t\t\tBN_print(bp,d);\n\t\t\t\t\tBIO_puts(bp, " ^ 2 - ");\n\t\t\t\t\tBN_print(bp,a);\n\t\t\t\t\tBIO_puts(bp,"\\n");\n\t\t\t\t\t}\n\t\t\t\t}\n#endif\n\t\t\tBN_GF2m_add(f, c, e);\n\t\t\tif(!BN_is_zero(f))\n\t\t\t\t{\n\t\t\t\tfprintf(stderr,"GF(2^m) modular square root test failed!\\n");\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tret = 1;\n  err:\n\tBN_free(a);\n\tBN_free(b[0]);\n\tBN_free(b[1]);\n\tBN_free(c);\n\tBN_free(d);\n\tBN_free(e);\n\tBN_free(f);\n\treturn ret;\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}', 'int\tBN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p)\n\t{\n\tint ret = 0;\n\tconst int max = BN_num_bits(p) + 1;\n\tint *arr=NULL;\n\tbn_check_top(a);\n\tbn_check_top(p);\n\tif ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL) goto err;\n\tret = BN_GF2m_poly2arr(p, arr, max);\n\tif (!ret || ret > max)\n\t\t{\n\t\tBNerr(BN_F_BN_GF2M_MOD,BN_R_INVALID_LENGTH);\n\t\tgoto err;\n\t\t}\n\tret = BN_GF2m_mod_arr(r, a, arr);\n\tbn_check_top(r);\nerr:\n\tif (arr) OPENSSL_free(arr);\n\treturn ret;\n\t}', 'int BN_num_bits(const BIGNUM *a)\n\t{\n\tint i = a->top - 1;\n\tbn_check_top(a);\n\tif (BN_is_zero(a)) return 0;\n\treturn ((i*BN_BITS2) + BN_num_bits_word(a->d[i]));\n\t}']