crypto/ec/ec_key.c:378: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `ec_key_public_range_check`.
Showing all 10 steps of the trace


crypto/ec/ec_key.c:378:10: Call
376.   
377.       /* 5.6.2.3.3 (Step 2) Test if the public key is in range */
378.       if (!ec_key_public_range_check(ctx, eckey)) {
                ^
379.           ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_COORDINATES_OUT_OF_RANGE);
380.           goto err;

crypto/ec/ec_key.c:310:1: Parameter `ctx->stack.depth`
  308.    * Returns 1 if the public key has a valid range, otherwise it returns 0.
  309.    */
  310. > static int ec_key_public_range_check(BN_CTX *ctx, const EC_KEY *key)
  311.   {
  312.       int ret = 0;

crypto/ec/ec_key.c:315:5: Call
  313.       BIGNUM *x, *y;
  314.   
  315.       BN_CTX_start(ctx);
             ^
  316.       x = BN_CTX_get(ctx);
  317.       y = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:171:1: Parameter `ctx->stack.depth`
    169.   }
    170.   
    171. > void BN_CTX_start(BN_CTX *ctx)
    172.   {
    173.       CTXDBG("ENTER BN_CTX_start()", ctx);

crypto/ec/ec_key.c:339:5: Call
  337.       ret = 1;
  338.   err:
  339.       BN_CTX_end(ctx);
             ^
  340.       return ret;
  341.   }

crypto/bn/bn_ctx.c:185:1: Parameter `ctx->stack.depth`
    183.   }
    184.   
    185. > void BN_CTX_end(BN_CTX *ctx)
    186.   {
    187.       if (ctx == NULL)

crypto/bn/bn_ctx.c:193:27: Call
    191.           ctx->err_stack--;
    192.       else {
    193.           unsigned int fp = BN_STACK_pop(&ctx->stack);
                                     ^
    194.           /* Does this stack frame have anything to release? */
    195.           if (fp < ctx->used)

crypto/bn/bn_ctx.c:268:1: <LHS trace>
266.   }
267.   
268. > static unsigned int BN_STACK_pop(BN_STACK *st)
269.   {
270.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:268:1: Parameter `st->depth`
      266.   }
      267.   
      268. > static unsigned int BN_STACK_pop(BN_STACK *st)
      269.   {
      270.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:270:12: Binary operation: ([0, +oo] - 1):unsigned32 by call to `ec_key_public_range_check` 
      268.   static unsigned int BN_STACK_pop(BN_STACK *st)
      269.   {
      270.       return st->indexes[--(st->depth)];
                        ^
      271.   }
      272.   

static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['int ec_key_simple_check_key(const EC_KEY *eckey)\n{\n    int ok = 0;\n    BN_CTX *ctx = NULL;\n    const BIGNUM *order = NULL;\n    EC_POINT *point = NULL;\n    if (eckey == NULL || eckey->group == NULL || eckey->pub_key == NULL) {\n        ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, ERR_R_PASSED_NULL_PARAMETER);\n        return 0;\n    }\n    if (EC_POINT_is_at_infinity(eckey->group, eckey->pub_key)) {\n        ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_POINT_AT_INFINITY);\n        goto err;\n    }\n    if ((ctx = BN_CTX_new()) == NULL)\n        goto err;\n    if ((point = EC_POINT_new(eckey->group)) == NULL)\n        goto err;\n    if (!ec_key_public_range_check(ctx, eckey)) {\n        ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_COORDINATES_OUT_OF_RANGE);\n        goto err;\n    }\n    if (EC_POINT_is_on_curve(eckey->group, eckey->pub_key, ctx) <= 0) {\n        ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_POINT_IS_NOT_ON_CURVE);\n        goto err;\n    }\n    order = eckey->group->order;\n    if (BN_is_zero(order)) {\n        ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_INVALID_GROUP_ORDER);\n        goto err;\n    }\n    if (!EC_POINT_mul(eckey->group, point, NULL, eckey->pub_key, order, ctx)) {\n        ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, ERR_R_EC_LIB);\n        goto err;\n    }\n    if (!EC_POINT_is_at_infinity(eckey->group, point)) {\n        ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_WRONG_ORDER);\n        goto err;\n    }\n    if (eckey->priv_key != NULL) {\n        if (BN_cmp(eckey->priv_key, BN_value_one()) < 0\n                || BN_cmp(eckey->priv_key, order) >= 0) {\n            ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_WRONG_ORDER);\n            goto err;\n        }\n        if (!EC_POINT_mul(eckey->group, point, eckey->priv_key,\n                          NULL, NULL, ctx)) {\n            ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, ERR_R_EC_LIB);\n            goto err;\n        }\n        if (EC_POINT_cmp(eckey->group, point, eckey->pub_key, ctx) != 0) {\n            ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_INVALID_PRIVATE_KEY);\n            goto err;\n        }\n    }\n    ok = 1;\n err:\n    BN_CTX_free(ctx);\n    EC_POINT_free(point);\n    return ok;\n}', 'static int ec_key_public_range_check(BN_CTX *ctx, const EC_KEY *key)\n{\n    int ret = 0;\n    BIGNUM *x, *y;\n    BN_CTX_start(ctx);\n    x = BN_CTX_get(ctx);\n    y = BN_CTX_get(ctx);\n    if (y == NULL)\n        goto err;\n    if (!EC_POINT_get_affine_coordinates(key->group, key->pub_key, x, y, ctx))\n        goto err;\n    if (EC_METHOD_get_field_type(key->group->meth) == NID_X9_62_prime_field) {\n        if (BN_is_negative(x)\n            || BN_cmp(x, key->group->field) >= 0\n            || BN_is_negative(y)\n            || BN_cmp(y, key->group->field) >= 0) {\n            goto err;\n        }\n    } else {\n        int m = EC_GROUP_get_degree(key->group);\n        if (BN_num_bits(x) > m || BN_num_bits(y) > m) {\n            goto err;\n        }\n    }\n    ret = 1;\nerr:\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}']