apps/apps.c:1711: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned64 by call to `BN_to_ASN1_INTEGER`.
Showing all 9 steps of the trace


apps/apps.c:1709:7: Call
1707.   		return 0;
1708.   
1709.   	if (!BN_pseudo_rand(btmp, SERIAL_RAND_BITS, 0, 0))
              ^
1710.   		goto error;
1711.   	if (ai && !BN_to_ASN1_INTEGER(btmp, ai))

crypto/bn/bn_rand.c:218:9: Call
  216.   int     BN_pseudo_rand(BIGNUM *rnd, size_t bits, int top, int bottom)
  217.   	{
  218.   	return bnrand(1, rnd, bits, top, bottom);
                 ^
  219.   	}
  220.   

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;

apps/apps.c:1711:13: Call
1709.   	if (!BN_pseudo_rand(btmp, SERIAL_RAND_BITS, 0, 0))
1710.   		goto error;
1711.   	if (ai && !BN_to_ASN1_INTEGER(btmp, ai))
                    ^
1712.   		goto error;
1713.   

crypto/asn1/a_int.c:405:1: Parameter `bn->top`
  403.   	}
  404.   
  405. > ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai)
  406.   	{
  407.   	ASN1_INTEGER *ret;

crypto/asn1/a_int.c:422:4: Call
  420.   		ret->type = V_ASN1_NEG_INTEGER;
  421.   	else ret->type=V_ASN1_INTEGER;
  422.   	j=BN_num_bits(bn);
            ^
  423.   	len=((j == 0)?0:((j/8)+1));
  424.   	if (ret->length < len+4)

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_to_ASN1_INTEGER` 
    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 rand_serial(BIGNUM *b, ASN1_INTEGER *ai)\n\t{\n\tBIGNUM *btmp;\n\tint ret = 0;\n\tif (b)\n\t\tbtmp = b;\n\telse\n\t\tbtmp = BN_new();\n\tif (!btmp)\n\t\treturn 0;\n\tif (!BN_pseudo_rand(btmp, SERIAL_RAND_BITS, 0, 0))\n\t\tgoto error;\n\tif (ai && !BN_to_ASN1_INTEGER(btmp, ai))\n\t\tgoto error;\n\tret = 1;\n\terror:\n\tif (!b)\n\t\tBN_free(btmp);\n\treturn ret;\n\t}', 'int     BN_pseudo_rand(BIGNUM *rnd, size_t bits, int top, int bottom)\n\t{\n\treturn bnrand(1, 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}', 'ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai)\n\t{\n\tASN1_INTEGER *ret;\n\tsize_t len,j;\n\tif (ai == NULL)\n\t\tret=M_ASN1_INTEGER_new();\n\telse\n\t\tret=ai;\n\tif (ret == NULL)\n\t\t{\n\t\tASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_NESTED_ASN1_ERROR);\n\t\tgoto err;\n\t\t}\n\tif (BN_is_negative(bn))\n\t\tret->type = V_ASN1_NEG_INTEGER;\n\telse ret->type=V_ASN1_INTEGER;\n\tj=BN_num_bits(bn);\n\tlen=((j == 0)?0:((j/8)+1));\n\tif (ret->length < len+4)\n\t\t{\n\t\tunsigned char *new_data=OPENSSL_realloc(ret->data, len+4U);\n\t\tif (!new_data)\n\t\t\t{\n\t\t\tASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_MALLOC_FAILURE);\n\t\t\tgoto err;\n\t\t\t}\n\t\tret->data=new_data;\n\t\t}\n\tret->length=BN_bn2bin(bn,ret->data);\n\tif(!ret->length)\n\t\t{\n\t\tret->data[0] = 0;\n\t\tret->length = 1;\n\t\t}\n\treturn(ret);\nerr:\n\tif (ret != ai) M_ASN1_INTEGER_free(ret);\n\treturn(NULL);\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}']