crypto/ec/ec_asn1.c:819: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `ec_curve_nid_from_params`.
Showing all 12 steps of the trace


crypto/ec/ec_asn1.c:763:10: Call
761.   
762.       /* extract the ec point */
763.       if (!EC_POINT_oct2point(ret, point, params->base->data,
                ^
764.                               params->base->length, NULL)) {
765.           ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB);

crypto/ec/ec_oct.c:101:1: Parameter `ctx->stack.depth`
  99.   }
  100.   
  101. > int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point,
  102.                          const unsigned char *buf, size_t len, BN_CTX *ctx)
  103.   {

crypto/ec/ec_asn1.c:819:23: Call
817.           goto err;
818.       }
819.       if ((curve_name = ec_curve_nid_from_params(dup, ctx)) != NID_undef) {
                             ^
820.           /*
821.            * The input explicit parameters successfully matched one of the

crypto/ec/ec_curve.c:3330:1: Parameter `ctx->stack.depth`
  3328.    *          if not found. If there was an error it returns -1.
  3329.    */
  3330. > int ec_curve_nid_from_params(const EC_GROUP *group, BN_CTX *ctx)
  3331.   {
  3332.       int ret = -1, nid, len, field_type, param_len;

crypto/ec/ec_curve.c:3353:5: Call
  3351.       cofactor = EC_GROUP_get0_cofactor(group);
  3352.   
  3353.       BN_CTX_start(ctx);
              ^
  3354.   
  3355.       /*

crypto/bn/bn_ctx.c:194:1: Parameter `ctx->stack.depth`
    192.   }
    193.   
    194. > void BN_CTX_start(BN_CTX *ctx)
    195.   {
    196.       CTXDBG("ENTER BN_CTX_start()", ctx);

crypto/ec/ec_curve.c:3429:5: Call
  3427.   end:
  3428.       OPENSSL_free(param_bytes);
  3429.       BN_CTX_end(ctx);
              ^
  3430.       return ret;
  3431.   }

crypto/bn/bn_ctx.c:208:1: Parameter `ctx->stack.depth`
    206.   }
    207.   
    208. > void BN_CTX_end(BN_CTX *ctx)
    209.   {
    210.       if (ctx == NULL)

crypto/bn/bn_ctx.c:216:27: Call
    214.           ctx->err_stack--;
    215.       else {
    216.           unsigned int fp = BN_STACK_pop(&ctx->stack);
                                     ^
    217.           /* Does this stack frame have anything to release? */
    218.           if (fp < ctx->used)

crypto/bn/bn_ctx.c:298:1: <LHS trace>
296.   }
297.   
298. > static unsigned int BN_STACK_pop(BN_STACK *st)
299.   {
300.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:298:1: Parameter `st->depth`
      296.   }
      297.   
      298. > static unsigned int BN_STACK_pop(BN_STACK *st)
      299.   {
      300.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:300:12: Binary operation: ([0, +oo] - 1):unsigned32 by call to `ec_curve_nid_from_params` 
      298.   static unsigned int BN_STACK_pop(BN_STACK *st)
      299.   {
      300.       return st->indexes[--(st->depth)];
                        ^
      301.   }
      302.   

static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params)\n{\n    int ok = 0, tmp;\n    EC_GROUP *ret = NULL, *dup = NULL;\n    BIGNUM *p = NULL, *a = NULL, *b = NULL;\n    EC_POINT *point = NULL;\n    long field_bits;\n    int curve_name = NID_undef;\n    BN_CTX *ctx = NULL;\n    if (!params->fieldID || !params->fieldID->fieldType ||\n        !params->fieldID->p.ptr) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n        goto err;\n    }\n    if (!params->curve || !params->curve->a ||\n        !params->curve->a->data || !params->curve->b ||\n        !params->curve->b->data) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n        goto err;\n    }\n    a = BN_bin2bn(params->curve->a->data, params->curve->a->length, NULL);\n    if (a == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_BN_LIB);\n        goto err;\n    }\n    b = BN_bin2bn(params->curve->b->data, params->curve->b->length, NULL);\n    if (b == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_BN_LIB);\n        goto err;\n    }\n    tmp = OBJ_obj2nid(params->fieldID->fieldType);\n    if (tmp == NID_X9_62_characteristic_two_field)\n#ifdef OPENSSL_NO_EC2M\n    {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_GF2M_NOT_SUPPORTED);\n        goto err;\n    }\n#else\n    {\n        X9_62_CHARACTERISTIC_TWO *char_two;\n        char_two = params->fieldID->p.char_two;\n        field_bits = char_two->m;\n        if (field_bits > OPENSSL_ECC_MAX_FIELD_BITS) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_FIELD_TOO_LARGE);\n            goto err;\n        }\n        if ((p = BN_new()) == NULL) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n        tmp = OBJ_obj2nid(char_two->type);\n        if (tmp == NID_X9_62_tpBasis) {\n            long tmp_long;\n            if (!char_two->p.tpBasis) {\n                ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n                goto err;\n            }\n            tmp_long = ASN1_INTEGER_get(char_two->p.tpBasis);\n            if (!(char_two->m > tmp_long && tmp_long > 0)) {\n                ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS,\n                      EC_R_INVALID_TRINOMIAL_BASIS);\n                goto err;\n            }\n            if (!BN_set_bit(p, (int)char_two->m))\n                goto err;\n            if (!BN_set_bit(p, (int)tmp_long))\n                goto err;\n            if (!BN_set_bit(p, 0))\n                goto err;\n        } else if (tmp == NID_X9_62_ppBasis) {\n            X9_62_PENTANOMIAL *penta;\n            penta = char_two->p.ppBasis;\n            if (!penta) {\n                ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n                goto err;\n            }\n            if (!\n                (char_two->m > penta->k3 && penta->k3 > penta->k2\n                 && penta->k2 > penta->k1 && penta->k1 > 0)) {\n                ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS,\n                      EC_R_INVALID_PENTANOMIAL_BASIS);\n                goto err;\n            }\n            if (!BN_set_bit(p, (int)char_two->m))\n                goto err;\n            if (!BN_set_bit(p, (int)penta->k1))\n                goto err;\n            if (!BN_set_bit(p, (int)penta->k2))\n                goto err;\n            if (!BN_set_bit(p, (int)penta->k3))\n                goto err;\n            if (!BN_set_bit(p, 0))\n                goto err;\n        } else if (tmp == NID_X9_62_onBasis) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_NOT_IMPLEMENTED);\n            goto err;\n        } else {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n            goto err;\n        }\n        ret = EC_GROUP_new_curve_GF2m(p, a, b, NULL);\n    }\n#endif\n    else if (tmp == NID_X9_62_prime_field) {\n        if (!params->fieldID->p.prime) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n            goto err;\n        }\n        p = ASN1_INTEGER_to_BN(params->fieldID->p.prime, NULL);\n        if (p == NULL) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_ASN1_LIB);\n            goto err;\n        }\n        if (BN_is_negative(p) || BN_is_zero(p)) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_INVALID_FIELD);\n            goto err;\n        }\n        field_bits = BN_num_bits(p);\n        if (field_bits > OPENSSL_ECC_MAX_FIELD_BITS) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_FIELD_TOO_LARGE);\n            goto err;\n        }\n        ret = EC_GROUP_new_curve_GFp(p, a, b, NULL);\n    } else {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_INVALID_FIELD);\n        goto err;\n    }\n    if (ret == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB);\n        goto err;\n    }\n    if (params->curve->seed != NULL) {\n        OPENSSL_free(ret->seed);\n        if ((ret->seed = OPENSSL_malloc(params->curve->seed->length)) == NULL) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n        memcpy(ret->seed, params->curve->seed->data,\n               params->curve->seed->length);\n        ret->seed_len = params->curve->seed->length;\n    }\n    if (!params->order || !params->base || !params->base->data) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);\n        goto err;\n    }\n    if ((point = EC_POINT_new(ret)) == NULL)\n        goto err;\n    EC_GROUP_set_point_conversion_form(ret, (point_conversion_form_t)\n                                       (params->base->data[0] & ~0x01));\n    if (!EC_POINT_oct2point(ret, point, params->base->data,\n                            params->base->length, NULL)) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB);\n        goto err;\n    }\n    if ((a = ASN1_INTEGER_to_BN(params->order, a)) == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_ASN1_LIB);\n        goto err;\n    }\n    if (BN_is_negative(a) || BN_is_zero(a)) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_INVALID_GROUP_ORDER);\n        goto err;\n    }\n    if (BN_num_bits(a) > (int)field_bits + 1) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_INVALID_GROUP_ORDER);\n        goto err;\n    }\n    if (params->cofactor == NULL) {\n        BN_free(b);\n        b = NULL;\n    } else if ((b = ASN1_INTEGER_to_BN(params->cofactor, b)) == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_ASN1_LIB);\n        goto err;\n    }\n    if (!EC_GROUP_set_generator(ret, point, a, b)) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB);\n        goto err;\n    }\n    if ((ctx = BN_CTX_new()) == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_BN_LIB);\n        goto err;\n    }\n    if ((dup = EC_GROUP_dup(ret)) == NULL\n            || EC_GROUP_set_seed(dup, NULL, 0) != 1\n            || !EC_GROUP_set_generator(dup, point, a, NULL)) {\n        ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB);\n        goto err;\n    }\n    if ((curve_name = ec_curve_nid_from_params(dup, ctx)) != NID_undef) {\n        EC_GROUP *named_group = NULL;\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n        if (curve_name == NID_wap_wsg_idm_ecid_wtls12)\n            curve_name = NID_secp224r1;\n#endif\n        if ((named_group = EC_GROUP_new_by_curve_name(curve_name)) == NULL) {\n            ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB);\n            goto err;\n        }\n        EC_GROUP_free(ret);\n        ret = named_group;\n        EC_GROUP_set_asn1_flag(ret, OPENSSL_EC_EXPLICIT_CURVE);\n    }\n    ok = 1;\n err:\n    if (!ok) {\n        EC_GROUP_free(ret);\n        ret = NULL;\n    }\n    EC_GROUP_free(dup);\n    BN_free(p);\n    BN_free(a);\n    BN_free(b);\n    EC_POINT_free(point);\n    BN_CTX_free(ctx);\n    return ret;\n}', 'int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point,\n                       const unsigned char *buf, size_t len, BN_CTX *ctx)\n{\n    if (group->meth->oct2point == 0\n        && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) {\n        ECerr(EC_F_EC_POINT_OCT2POINT, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    if (!ec_point_is_compat(point, group)) {\n        ECerr(EC_F_EC_POINT_OCT2POINT, EC_R_INCOMPATIBLE_OBJECTS);\n        return 0;\n    }\n    if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) {\n        if (group->meth->field_type == NID_X9_62_prime_field)\n            return ec_GFp_simple_oct2point(group, point, buf, len, ctx);\n        else\n#ifdef OPENSSL_NO_EC2M\n        {\n            ECerr(EC_F_EC_POINT_OCT2POINT, EC_R_GF2M_NOT_SUPPORTED);\n            return 0;\n        }\n#else\n            return ec_GF2m_simple_oct2point(group, point, buf, len, ctx);\n#endif\n    }\n    return group->meth->oct2point(group, point, buf, len, ctx);\n}', 'int ec_curve_nid_from_params(const EC_GROUP *group, BN_CTX *ctx)\n{\n    int ret = -1, nid, len, field_type, param_len;\n    size_t i, seed_len;\n    const unsigned char *seed, *params_seed, *params;\n    unsigned char *param_bytes = NULL;\n    const EC_CURVE_DATA *data;\n    const EC_POINT *generator = NULL;\n    const EC_METHOD *meth;\n    const BIGNUM *cofactor = NULL;\n    BIGNUM *bn[NUM_BN_FIELDS] = {NULL, NULL, NULL, NULL, NULL, NULL};\n    meth = EC_GROUP_method_of(group);\n    if (meth == NULL)\n        return -1;\n    nid = EC_GROUP_get_curve_name(group);\n    field_type = EC_METHOD_get_field_type(meth);\n    seed_len = EC_GROUP_get_seed_len(group);\n    seed = EC_GROUP_get0_seed(group);\n    cofactor = EC_GROUP_get0_cofactor(group);\n    BN_CTX_start(ctx);\n    param_len = BN_num_bytes(group->order);\n    len = BN_num_bytes(group->field);\n    if (len > param_len)\n        param_len = len;\n    param_bytes = OPENSSL_malloc(param_len * NUM_BN_FIELDS);\n    if (param_bytes == NULL)\n        goto end;\n    for (i = 0; i < NUM_BN_FIELDS; ++i) {\n        if ((bn[i] = BN_CTX_get(ctx)) == NULL)\n            goto end;\n    }\n    if (!(EC_GROUP_get_curve(group, bn[0], bn[1], bn[2], ctx)\n        && ((generator = EC_GROUP_get0_generator(group)) != NULL)\n        && EC_POINT_get_affine_coordinates(group, generator, bn[3], bn[4], ctx)\n        && EC_GROUP_get_order(group, bn[5], ctx)))\n        goto end;\n    for (i = 0; i < NUM_BN_FIELDS; ++i) {\n        if (BN_bn2binpad(bn[i], &param_bytes[i*param_len], param_len) <= 0)\n            goto end;\n    }\n    for (i = 0; i < curve_list_length; i++) {\n        const ec_list_element curve = curve_list[i];\n        data = curve.data;\n        params_seed = (const unsigned char *)(data + 1);\n        params = params_seed + data->seed_len;\n        if (data->field_type == field_type\n            && param_len == data->param_len\n            && (nid <= 0 || nid == curve.nid)\n            && (BN_is_zero(cofactor)\n                || BN_is_word(cofactor, (const BN_ULONG)curve.data->cofactor))\n            && (data->seed_len == 0 || seed_len == 0\n                || ((size_t)data->seed_len == seed_len\n                     && memcmp(params_seed, seed, seed_len) == 0))\n            && memcmp(param_bytes, params, param_len * NUM_BN_FIELDS)\n                             == 0) {\n            ret = curve.nid;\n            goto end;\n        }\n    }\n    ret = NID_undef;\nend:\n    OPENSSL_free(param_bytes);\n    BN_CTX_end(ctx);\n    return ret;\n}', 'void BN_CTX_start(BN_CTX *ctx)\n{\n    CTXDBG("ENTER BN_CTX_start()", ctx);\n    if (ctx->err_stack || ctx->too_many)\n        ctx->err_stack++;\n    else if (!BN_STACK_push(&ctx->stack, ctx->used)) {\n        BNerr(BN_F_BN_CTX_START, BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n        ctx->err_stack++;\n    }\n    CTXDBG("LEAVE BN_CTX_start()", ctx);\n}', 'void BN_CTX_end(BN_CTX *ctx)\n{\n    if (ctx == NULL)\n        return;\n    CTXDBG("ENTER BN_CTX_end()", ctx);\n    if (ctx->err_stack)\n        ctx->err_stack--;\n    else {\n        unsigned int fp = BN_STACK_pop(&ctx->stack);\n        if (fp < ctx->used)\n            BN_POOL_release(&ctx->pool, ctx->used - fp);\n        ctx->used = fp;\n        ctx->too_many = 0;\n    }\n    CTXDBG("LEAVE BN_CTX_end()", ctx);\n}', 'static unsigned int BN_STACK_pop(BN_STACK *st)\n{\n    return st->indexes[--(st->depth)];\n}']