crypto/ec/ecp_smpl.c:327: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `BN_mod_sqr`.
Showing all 23 steps of the trace


crypto/ec/ecp_smpl.c:282:1: Parameter `ctx->pool.used`
280.   }
281.   
282. > int ec_GFp_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx)
283.   {
284.       int ret = 0;

crypto/ec/ecp_smpl.c:298:9: Call
296.       }
297.       BN_CTX_start(ctx);
298.       a = BN_CTX_get(ctx);
               ^
299.       b = BN_CTX_get(ctx);
300.       tmp_1 = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:271:1: Parameter `ctx->pool.used`
  269.   }
  270.   
  271. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
  272.   {
  273.       BIGNUM *ret;

crypto/ec/ecp_smpl.c:299:9: Call
297.       BN_CTX_start(ctx);
298.       a = BN_CTX_get(ctx);
299.       b = BN_CTX_get(ctx);
               ^
300.       tmp_1 = BN_CTX_get(ctx);
301.       tmp_2 = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:271:1: Parameter `ctx->pool.used`
  269.   }
  270.   
  271. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
  272.   {
  273.       BIGNUM *ret;

crypto/ec/ecp_smpl.c:300:13: Call
298.       a = BN_CTX_get(ctx);
299.       b = BN_CTX_get(ctx);
300.       tmp_1 = BN_CTX_get(ctx);
                   ^
301.       tmp_2 = BN_CTX_get(ctx);
302.       order = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:271:1: Parameter `ctx->pool.used`
  269.   }
  270.   
  271. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
  272.   {
  273.       BIGNUM *ret;

crypto/ec/ecp_smpl.c:301:13: Call
299.       b = BN_CTX_get(ctx);
300.       tmp_1 = BN_CTX_get(ctx);
301.       tmp_2 = BN_CTX_get(ctx);
                   ^
302.       order = BN_CTX_get(ctx);
303.       if (order == NULL)

crypto/bn/bn_ctx.c:271:1: Parameter `ctx->pool.used`
  269.   }
  270.   
  271. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
  272.   {
  273.       BIGNUM *ret;

crypto/ec/ecp_smpl.c:302:13: Call
300.       tmp_1 = BN_CTX_get(ctx);
301.       tmp_2 = BN_CTX_get(ctx);
302.       order = BN_CTX_get(ctx);
                   ^
303.       if (order == NULL)
304.           goto err;

crypto/bn/bn_ctx.c:271:1: Parameter `ctx->pool.used`
  269.   }
  270.   
  271. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
  272.   {
  273.       BIGNUM *ret;

crypto/ec/ecp_smpl.c:327:14: Call
325.               goto err;
326.       } else if (!BN_is_zero(b)) {
327.           if (!BN_mod_sqr(tmp_1, a, p, ctx))
                    ^
328.               goto err;
329.           if (!BN_mod_mul(tmp_2, tmp_1, a, p, ctx))

crypto/bn/bn_mod.c:208:1: Parameter `ctx->pool.used`
  206.   }
  207.   
  208. > int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)
  209.   {
  210.       if (!BN_sqr(r, a, ctx))

crypto/bn/bn_mod.c:210:10: Call
  208.   int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)
  209.   {
  210.       if (!BN_sqr(r, a, ctx))
                  ^
  211.           return 0;
  212.       /* r->neg == 0,  thus we don't need BN_nnmod */

crypto/bn/bn_sqr.c:66:1: Parameter `ctx->pool.used`
    64.    * I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96
    65.    */
    66. > int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
    67.   {
    68.       int max, al;

crypto/bn/bn_sqr.c:83:11: Call
    81.       BN_CTX_start(ctx);
    82.       rr = (a != r) ? r : BN_CTX_get(ctx);
    83.       tmp = BN_CTX_get(ctx);
                    ^
    84.       if (!rr || !tmp)
    85.           goto err;

crypto/bn/bn_ctx.c:271:1: Parameter `ctx->pool.used`
      269.   }
      270.   
      271. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
      272.   {
      273.       BIGNUM *ret;

crypto/bn/bn_sqr.c:148:5: Call
    146.       bn_check_top(rr);
    147.       bn_check_top(tmp);
    148.       BN_CTX_end(ctx);
               ^
    149.       return (ret);
    150.   }

crypto/bn/bn_ctx.c:254:1: Parameter `ctx->pool.used`
      252.   }
      253.   
      254. > void BN_CTX_end(BN_CTX *ctx)
      255.   {
      256.       CTXDBG_ENTRY("BN_CTX_end", ctx);

crypto/bn/bn_ctx.c:263:13: Call
      261.           /* Does this stack frame have anything to release? */
      262.           if (fp < ctx->used)
      263.               BN_POOL_release(&ctx->pool, ctx->used - fp);
                         ^
      264.           ctx->used = fp;
      265.           /* Unjam "too_many" in case "get" had failed */

crypto/bn/bn_ctx.c:399:1: <LHS trace>
397.   }
398.   
399. > static void BN_POOL_release(BN_POOL *p, unsigned int num)
400.   {
401.       unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;

crypto/bn/bn_ctx.c:399:1: Parameter `p->used`
        397.   }
        398.   
        399. > static void BN_POOL_release(BN_POOL *p, unsigned int num)
        400.   {
        401.       unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;

crypto/bn/bn_ctx.c:401:5: Binary operation: ([0, +oo] - 1):unsigned32 by call to `BN_mod_sqr` 
        399.   static void BN_POOL_release(BN_POOL *p, unsigned int num)
        400.   {
        401.       unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;
                   ^
        402.   
        403.       p->used -= num;

static void BN_POOL_release(BN_POOL *p, unsigned int num)
{
    unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;
    p->used -= num;
    while (num--) {
        bn_check_top(p->current->vals + offset);
        if (offset == 0) {
            offset = BN_CTX_POOL_SIZE - 1;
            p->current = p->current->prev;
        } else
            offset--;
    }
}
['int ec_GFp_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx)\n{\n    int ret = 0;\n    BIGNUM *a, *b, *order, *tmp_1, *tmp_2;\n    const BIGNUM *p = group->field;\n    BN_CTX *new_ctx = NULL;\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL) {\n            ECerr(EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT,\n                  ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n    }\n    BN_CTX_start(ctx);\n    a = BN_CTX_get(ctx);\n    b = BN_CTX_get(ctx);\n    tmp_1 = BN_CTX_get(ctx);\n    tmp_2 = BN_CTX_get(ctx);\n    order = BN_CTX_get(ctx);\n    if (order == NULL)\n        goto err;\n    if (group->meth->field_decode) {\n        if (!group->meth->field_decode(group, a, group->a, ctx))\n            goto err;\n        if (!group->meth->field_decode(group, b, group->b, ctx))\n            goto err;\n    } else {\n        if (!BN_copy(a, group->a))\n            goto err;\n        if (!BN_copy(b, group->b))\n            goto err;\n    }\n    if (BN_is_zero(a)) {\n        if (BN_is_zero(b))\n            goto err;\n    } else if (!BN_is_zero(b)) {\n        if (!BN_mod_sqr(tmp_1, a, p, ctx))\n            goto err;\n        if (!BN_mod_mul(tmp_2, tmp_1, a, p, ctx))\n            goto err;\n        if (!BN_lshift(tmp_1, tmp_2, 2))\n            goto err;\n        if (!BN_mod_sqr(tmp_2, b, p, ctx))\n            goto err;\n        if (!BN_mul_word(tmp_2, 27))\n            goto err;\n        if (!BN_mod_add(a, tmp_1, tmp_2, p, ctx))\n            goto err;\n        if (BN_is_zero(a))\n            goto err;\n    }\n    ret = 1;\n err:\n    if (ctx != NULL)\n        BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\n    return ret;\n}', 'BIGNUM *BN_CTX_get(BN_CTX *ctx)\n{\n    BIGNUM *ret;\n    CTXDBG_ENTRY("BN_CTX_get", ctx);\n    if (ctx->err_stack || ctx->too_many)\n        return NULL;\n    if ((ret = BN_POOL_get(&ctx->pool, ctx->flags)) == NULL) {\n        ctx->too_many = 1;\n        BNerr(BN_F_BN_CTX_GET, BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n        return NULL;\n    }\n    BN_zero(ret);\n    ctx->used++;\n    CTXDBG_RET(ctx, ret);\n    return ret;\n}', 'int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)\n{\n    if (!BN_sqr(r, a, ctx))\n        return 0;\n    return BN_mod(r, r, m, ctx);\n}', 'int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)\n{\n    int max, al;\n    int ret = 0;\n    BIGNUM *tmp, *rr;\n    bn_check_top(a);\n    al = a->top;\n    if (al <= 0) {\n        r->top = 0;\n        r->neg = 0;\n        return 1;\n    }\n    BN_CTX_start(ctx);\n    rr = (a != r) ? r : BN_CTX_get(ctx);\n    tmp = BN_CTX_get(ctx);\n    if (!rr || !tmp)\n        goto err;\n    max = 2 * al;\n    if (bn_wexpand(rr, max) == NULL)\n        goto err;\n    if (al == 4) {\n#ifndef BN_SQR_COMBA\n        BN_ULONG t[8];\n        bn_sqr_normal(rr->d, a->d, 4, t);\n#else\n        bn_sqr_comba4(rr->d, a->d);\n#endif\n    } else if (al == 8) {\n#ifndef BN_SQR_COMBA\n        BN_ULONG t[16];\n        bn_sqr_normal(rr->d, a->d, 8, t);\n#else\n        bn_sqr_comba8(rr->d, a->d);\n#endif\n    } else {\n#if defined(BN_RECURSION)\n        if (al < BN_SQR_RECURSIVE_SIZE_NORMAL) {\n            BN_ULONG t[BN_SQR_RECURSIVE_SIZE_NORMAL * 2];\n            bn_sqr_normal(rr->d, a->d, al, t);\n        } else {\n            int j, k;\n            j = BN_num_bits_word((BN_ULONG)al);\n            j = 1 << (j - 1);\n            k = j + j;\n            if (al == j) {\n                if (bn_wexpand(tmp, k * 2) == NULL)\n                    goto err;\n                bn_sqr_recursive(rr->d, a->d, al, tmp->d);\n            } else {\n                if (bn_wexpand(tmp, max) == NULL)\n                    goto err;\n                bn_sqr_normal(rr->d, a->d, al, tmp->d);\n            }\n        }\n#else\n        if (bn_wexpand(tmp, max) == NULL)\n            goto err;\n        bn_sqr_normal(rr->d, a->d, al, tmp->d);\n#endif\n    }\n    rr->neg = 0;\n    if (a->d[al - 1] == (a->d[al - 1] & BN_MASK2l))\n        rr->top = max - 1;\n    else\n        rr->top = max;\n    if (rr != r)\n        BN_copy(r, rr);\n    ret = 1;\n err:\n    bn_check_top(rr);\n    bn_check_top(tmp);\n    BN_CTX_end(ctx);\n    return (ret);\n}', 'void BN_CTX_end(BN_CTX *ctx)\n{\n    CTXDBG_ENTRY("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_EXIT(ctx);\n}', 'static void BN_POOL_release(BN_POOL *p, unsigned int num)\n{\n    unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;\n    p->used -= num;\n    while (num--) {\n        bn_check_top(p->current->vals + offset);\n        if (offset == 0) {\n            offset = BN_CTX_POOL_SIZE - 1;\n            p->current = p->current->prev;\n        } else\n            offset--;\n    }\n}']