crypto/bn/bn_recp.c:77: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `BN_div_recp`.
Showing all 15 steps of the trace


crypto/bn/bn_recp.c:55:1: Parameter `ctx->pool.used`
53.   }
54.   
55. > int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,
56.                             BN_RECP_CTX *recp, BN_CTX *ctx)
57.   {

crypto/bn/bn_recp.c:63:14: Call
61.   
62.       BN_CTX_start(ctx);
63.       if ((a = BN_CTX_get(ctx)) == NULL)
                   ^
64.           goto err;
65.       if (y != NULL) {

crypto/bn/bn_ctx.c:227:1: Parameter `ctx->pool.used`
  225.   }
  226.   
  227. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
  228.   {
  229.       BIGNUM *ret;

crypto/bn/bn_recp.c:77:11: Call
75.           ca = x;                 /* Just do the mod */
76.   
77.       ret = BN_div_recp(NULL, r, ca, recp, ctx);
                ^
78.    err:
79.       BN_CTX_end(ctx);

crypto/bn/bn_recp.c:84:1: Parameter `ctx->pool.used`
  82.   }
  83.   
  84. > int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
  85.                   BN_RECP_CTX *recp, BN_CTX *ctx)
  86.   {

crypto/bn/bn_recp.c:93:9: Call
  91.       d = (dv != NULL) ? dv : BN_CTX_get(ctx);
  92.       r = (rem != NULL) ? rem : BN_CTX_get(ctx);
  93.       a = BN_CTX_get(ctx);
                ^
  94.       b = BN_CTX_get(ctx);
  95.       if (b == NULL)

crypto/bn/bn_ctx.c:227:1: Parameter `ctx->pool.used`
    225.   }
    226.   
    227. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
    228.   {
    229.       BIGNUM *ret;

crypto/bn/bn_recp.c:94:9: Call
  92.       r = (rem != NULL) ? rem : BN_CTX_get(ctx);
  93.       a = BN_CTX_get(ctx);
  94.       b = BN_CTX_get(ctx);
                ^
  95.       if (b == NULL)
  96.           goto err;

crypto/bn/bn_ctx.c:227:1: Parameter `ctx->pool.used`
    225.   }
    226.   
    227. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
    228.   {
    229.       BIGNUM *ret;

crypto/bn/bn_recp.c:101:13: Call
  99.           BN_zero(d);
  100.           if (!BN_copy(r, m)) {
  101.               BN_CTX_end(ctx);
                     ^
  102.               return 0;
  103.           }

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

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

crypto/bn/bn_ctx.c:370:1: <LHS trace>
368.   }
369.   
370. > static void BN_POOL_release(BN_POOL *p, unsigned int num)
371.   {
372.       unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;

crypto/bn/bn_ctx.c:370:1: Parameter `p->used`
      368.   }
      369.   
      370. > static void BN_POOL_release(BN_POOL *p, unsigned int num)
      371.   {
      372.       unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;

crypto/bn/bn_ctx.c:372:5: Binary operation: ([0, +oo] - 1):unsigned32 by call to `BN_div_recp` 
      370.   static void BN_POOL_release(BN_POOL *p, unsigned int num)
      371.   {
      372.       unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;
                 ^
      373.   
      374.       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 BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,\n                          BN_RECP_CTX *recp, BN_CTX *ctx)\n{\n    int ret = 0;\n    BIGNUM *a;\n    const BIGNUM *ca;\n    BN_CTX_start(ctx);\n    if ((a = BN_CTX_get(ctx)) == NULL)\n        goto err;\n    if (y != NULL) {\n        if (x == y) {\n            if (!BN_sqr(a, x, ctx))\n                goto err;\n        } else {\n            if (!BN_mul(a, x, y, ctx))\n                goto err;\n        }\n        ca = a;\n    } else\n        ca = x;\n    ret = BN_div_recp(NULL, r, ca, recp, ctx);\n err:\n    BN_CTX_end(ctx);\n    bn_check_top(r);\n    return ret;\n}', 'BIGNUM *BN_CTX_get(BN_CTX *ctx)\n{\n    BIGNUM *ret;\n    CTXDBG("ENTER 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    ret->flags &= (~BN_FLG_CONSTTIME);\n    ctx->used++;\n    CTXDBG("LEAVE BN_CTX_get()", ctx);\n    return ret;\n}', 'int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,\n                BN_RECP_CTX *recp, BN_CTX *ctx)\n{\n    int i, j, ret = 0;\n    BIGNUM *a, *b, *d, *r;\n    BN_CTX_start(ctx);\n    d = (dv != NULL) ? dv : BN_CTX_get(ctx);\n    r = (rem != NULL) ? rem : BN_CTX_get(ctx);\n    a = BN_CTX_get(ctx);\n    b = BN_CTX_get(ctx);\n    if (b == NULL)\n        goto err;\n    if (BN_ucmp(m, &(recp->N)) < 0) {\n        BN_zero(d);\n        if (!BN_copy(r, m)) {\n            BN_CTX_end(ctx);\n            return 0;\n        }\n        BN_CTX_end(ctx);\n        return 1;\n    }\n    i = BN_num_bits(m);\n    j = recp->num_bits << 1;\n    if (j > i)\n        i = j;\n    if (i != recp->shift)\n        recp->shift = BN_reciprocal(&(recp->Nr), &(recp->N), i, ctx);\n    if (recp->shift == -1)\n        goto err;\n    if (!BN_rshift(a, m, recp->num_bits))\n        goto err;\n    if (!BN_mul(b, a, &(recp->Nr), ctx))\n        goto err;\n    if (!BN_rshift(d, b, i - recp->num_bits))\n        goto err;\n    d->neg = 0;\n    if (!BN_mul(b, &(recp->N), d, ctx))\n        goto err;\n    if (!BN_usub(r, m, b))\n        goto err;\n    r->neg = 0;\n    j = 0;\n    while (BN_ucmp(r, &(recp->N)) >= 0) {\n        if (j++ > 2) {\n            BNerr(BN_F_BN_DIV_RECP, BN_R_BAD_RECIPROCAL);\n            goto err;\n        }\n        if (!BN_usub(r, r, &(recp->N)))\n            goto err;\n        if (!BN_add_word(d, 1))\n            goto err;\n    }\n    r->neg = BN_is_zero(r) ? 0 : m->neg;\n    d->neg = m->neg ^ recp->N.neg;\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    bn_check_top(dv);\n    bn_check_top(rem);\n    return ret;\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 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}']