crypto/ec/ec_asn1.c:887: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned64 by call to `BN_num_bits`.
Showing all 7 steps of the trace


crypto/ec/ec_asn1.c:874:7: Call
872.   			goto err;
873.   			}
874.   		p = ASN1_INTEGER_to_BN(params->fieldID->p.prime, NULL);
             ^
875.   		if (p == NULL)
876.   			{

crypto/asn1/a_int.c:451:11: Call
  449.   	BIGNUM *ret;
  450.   
  451.   	if ((ret=BN_bin2bn(ai->data,ai->length,bn)) == NULL)
                   ^
  452.   		ASN1err(ASN1_F_ASN1_INTEGER_TO_BN,ASN1_R_BN_LIB);
  453.   	else if(ai->type == V_ASN1_NEG_INTEGER)

crypto/bn/bn_lib.c:597:1: Parameter `ret->top`
    595.   	}
    596.   
    597. > BIGNUM *BN_bin2bn(const unsigned char *s, size_t len, BIGNUM *ret)
    598.   	{
    599.   	unsigned int i,m;

crypto/ec/ec_asn1.c:887:16: Call
885.   			}
886.   
887.   		field_bits = BN_num_bits(p);
                      ^
888.   		if (field_bits > OPENSSL_ECC_MAX_FIELD_BITS)
889.   			{

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_num_bits` 
  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]));
	}
['static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *params)\n\t{\n\tint\t\t\tok = 0, tmp;\n\tEC_GROUP\t\t*ret = NULL;\n\tBIGNUM\t\t\t*p = NULL, *a = NULL, *b = NULL;\n\tEC_POINT\t\t*point=NULL;\n\tlong    \t\tfield_bits;\n\tif (!params->fieldID || !params->fieldID->fieldType ||\n\t    !params->fieldID->p.ptr)\n\t\t{\n\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR);\n\t\tgoto err;\n\t\t}\n\tif (!params->curve || !params->curve->a ||\n\t    !params->curve->a->data || !params->curve->b ||\n\t    !params->curve->b->data)\n\t\t{\n\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR);\n\t\tgoto err;\n\t\t}\n\ta = BN_bin2bn(params->curve->a->data, params->curve->a->length, NULL);\n\tif (a == NULL)\n\t\t{\n\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_BN_LIB);\n\t\tgoto err;\n\t\t}\n\tb = BN_bin2bn(params->curve->b->data, params->curve->b->length, NULL);\n\tif (b == NULL)\n\t\t{\n\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_BN_LIB);\n\t\tgoto err;\n\t\t}\n\ttmp = OBJ_obj2nid(params->fieldID->fieldType);\n\tif (tmp == NID_X9_62_characteristic_two_field)\n\t\t{\n\t\tX9_62_CHARACTERISTIC_TWO *char_two;\n\t\tchar_two = params->fieldID->p.char_two;\n\t\tfield_bits = char_two->m;\n\t\tif (field_bits > OPENSSL_ECC_MAX_FIELD_BITS)\n\t\t\t{\n\t\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_FIELD_TOO_LARGE);\n\t\t\tgoto err;\n\t\t\t}\n\t\tif ((p = BN_new()) == NULL)\n\t\t\t{\n\t\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_MALLOC_FAILURE);\n\t\t\tgoto err;\n\t\t\t}\n\t\ttmp = OBJ_obj2nid(char_two->type);\n\t\tif (tmp ==  NID_X9_62_tpBasis)\n\t\t\t{\n\t\t\tlong tmp_long;\n\t\t\tif (!char_two->p.tpBasis)\n\t\t\t\t{\n\t\t\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\ttmp_long = ASN1_INTEGER_get(char_two->p.tpBasis);\n\t\t\tif (!(char_two->m > tmp_long && tmp_long > 0))\n\t\t\t\t{\n\t\t\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_TRINOMIAL_BASIS);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tif (!BN_set_bit(p, (int)char_two->m))\n\t\t\t\tgoto err;\n\t\t\tif (!BN_set_bit(p, (int)tmp_long))\n\t\t\t\tgoto err;\n\t\t\tif (!BN_set_bit(p, 0))\n\t\t\t\tgoto err;\n\t\t\t}\n\t\telse if (tmp == NID_X9_62_ppBasis)\n\t\t\t{\n\t\t\tX9_62_PENTANOMIAL *penta;\n\t\t\tpenta = char_two->p.ppBasis;\n\t\t\tif (!penta)\n\t\t\t\t{\n\t\t\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tif (!(char_two->m > penta->k3 && penta->k3 > penta->k2 && penta->k2 > penta->k1 && penta->k1 > 0))\n\t\t\t\t{\n\t\t\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_PENTANOMIAL_BASIS);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tif (!BN_set_bit(p, (int)char_two->m)) goto err;\n\t\t\tif (!BN_set_bit(p, (int)penta->k1)) goto err;\n\t\t\tif (!BN_set_bit(p, (int)penta->k2)) goto err;\n\t\t\tif (!BN_set_bit(p, (int)penta->k3)) goto err;\n\t\t\tif (!BN_set_bit(p, 0)) goto err;\n\t\t\t}\n\t\telse if (tmp == NID_X9_62_onBasis)\n\t\t\t{\n\t\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_NOT_IMPLEMENTED);\n\t\t\tgoto err;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR);\n\t\t\tgoto err;\n\t\t\t}\n\t\tret = EC_GROUP_new_curve_GF2m(p, a, b, NULL);\n\t\t}\n\telse if (tmp == NID_X9_62_prime_field)\n\t\t{\n\t\tif (!params->fieldID->p.prime)\n\t\t\t{\n\t\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR);\n\t\t\tgoto err;\n\t\t\t}\n\t\tp = ASN1_INTEGER_to_BN(params->fieldID->p.prime, NULL);\n\t\tif (p == NULL)\n\t\t\t{\n\t\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_ASN1_LIB);\n\t\t\tgoto err;\n\t\t\t}\n\t\tif (BN_is_negative(p) || BN_is_zero(p))\n\t\t\t{\n\t\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_FIELD);\n\t\t\tgoto err;\n\t\t\t}\n\t\tfield_bits = BN_num_bits(p);\n\t\tif (field_bits > OPENSSL_ECC_MAX_FIELD_BITS)\n\t\t\t{\n\t\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_FIELD_TOO_LARGE);\n\t\t\tgoto err;\n\t\t\t}\n\t\tret = EC_GROUP_new_curve_GFp(p, a, b, NULL);\n\t\t}\n\telse\n\t\t{\n\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_FIELD);\n\t\tgoto err;\n\t\t}\n\tif (ret == NULL)\n\t\t{\n\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_EC_LIB);\n\t\tgoto err;\n\t\t}\n\tif (params->curve->seed != NULL)\n\t\t{\n\t\tif (ret->seed != NULL)\n\t\t\tOPENSSL_free(ret->seed);\n\t\tif (!(ret->seed = OPENSSL_malloc(params->curve->seed->length)))\n\t\t\t{\n\t\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP,\n\t\t\t      ERR_R_MALLOC_FAILURE);\n\t\t\tgoto err;\n\t\t\t}\n\t\tmemcpy(ret->seed, params->curve->seed->data,\n\t\t       params->curve->seed->length);\n\t\tret->seed_len = params->curve->seed->length;\n\t\t}\n\tif (!params->order || !params->base || !params->base->data)\n\t\t{\n\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR);\n\t\tgoto err;\n\t\t}\n\tif ((point = EC_POINT_new(ret)) == NULL) goto err;\n\tEC_GROUP_set_point_conversion_form(ret, (point_conversion_form_t)\n\t\t\t\t(params->base->data[0] & ~0x01));\n\tif (!EC_POINT_oct2point(ret, point, params->base->data,\n\t\t                params->base->length, NULL))\n\t\t{\n\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_EC_LIB);\n\t\tgoto err;\n\t\t}\n\tif ((a = ASN1_INTEGER_to_BN(params->order, a)) == NULL)\n\t\t{\n\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_ASN1_LIB);\n\t\tgoto err;\n\t\t}\n\tif (BN_is_negative(a) || BN_is_zero(a))\n\t\t{\n\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_GROUP_ORDER);\n\t\tgoto err;\n\t\t}\n\tif (BN_num_bits(a) > (int)field_bits + 1)\n\t\t{\n\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_INVALID_GROUP_ORDER);\n\t\tgoto err;\n\t\t}\n\tif (params->cofactor == NULL)\n\t\t{\n\t\tif (b)\n\t\t\t{\n\t\t\tBN_free(b);\n\t\t\tb = NULL;\n\t\t\t}\n\t\t}\n\telse\n\t\tif ((b = ASN1_INTEGER_to_BN(params->cofactor, b)) == NULL)\n\t\t\t{\n\t\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_ASN1_LIB);\n\t\t\tgoto err;\n\t\t\t}\n\tif (!EC_GROUP_set_generator(ret, point, a, b))\n\t\t{\n\t\tECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_EC_LIB);\n\t\tgoto err;\n\t\t}\n\tok = 1;\nerr:\tif (!ok)\n\t\t{\n\t\tif (ret)\n\t\t\tEC_GROUP_clear_free(ret);\n\t\tret = NULL;\n\t\t}\n\tif (p)\n\t\tBN_free(p);\n\tif (a)\n\t\tBN_free(a);\n\tif (b)\n\t\tBN_free(b);\n\tif (point)\n\t\tEC_POINT_free(point);\n\treturn(ret);\n}', 'BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn)\n\t{\n\tBIGNUM *ret;\n\tif ((ret=BN_bin2bn(ai->data,ai->length,bn)) == NULL)\n\t\tASN1err(ASN1_F_ASN1_INTEGER_TO_BN,ASN1_R_BN_LIB);\n\telse if(ai->type == V_ASN1_NEG_INTEGER)\n\t\tBN_set_negative(ret, 1);\n\treturn(ret);\n\t}', 'BIGNUM *BN_bin2bn(const unsigned char *s, size_t len, BIGNUM *ret)\n\t{\n\tunsigned int i,m;\n\tunsigned int n;\n\tBN_ULONG l;\n\tBIGNUM  *bn = NULL;\n\tif (ret == NULL)\n\t\tret = bn = BN_new();\n\tif (ret == NULL) return(NULL);\n\tbn_check_top(ret);\n\tl=0;\n\tn=len;\n\tif (n == 0)\n\t\t{\n\t\tret->top=0;\n\t\treturn(ret);\n\t\t}\n\ti=((n-1)/BN_BYTES)+1;\n\tm=((n-1)%(BN_BYTES));\n\tif (bn_wexpand(ret, i) == NULL)\n\t\t{\n\t\tif (bn) BN_free(bn);\n\t\treturn NULL;\n\t\t}\n\tret->top=i;\n\tret->neg=0;\n\twhile (n--)\n\t\t{\n\t\tl=(l<<8L)| *(s++);\n\t\tif (m-- == 0)\n\t\t\t{\n\t\t\tret->d[--i]=l;\n\t\t\tl=0;\n\t\t\tm=BN_BYTES-1;\n\t\t\t}\n\t\t}\n\tbn_correct_top(ret);\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}']