crypto/bn/bn_blind.c:113: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `bn_mul_mont_fixed_top`.
Showing all 16 steps of the trace


crypto/bn/bn_blind.c:112:18: Call
110.       } else if (!(b->flags & BN_BLINDING_NO_UPDATE)) {
111.           if (b->m_ctx != NULL) {
112.               if (!bn_mul_mont_fixed_top(b->Ai, b->Ai, b->Ai, b->m_ctx, ctx)
                        ^
113.                   || !bn_mul_mont_fixed_top(b->A, b->A, b->A, b->m_ctx, ctx))
114.                   goto err;

crypto/bn/bn_mont.c:37:1: Parameter `ctx->pool.used`
  35.   }
  36.   
  37. > int bn_mul_mont_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
  38.                             BN_MONT_CTX *mont, BN_CTX *ctx)
  39.   {

crypto/bn/bn_blind.c:113:21: Call
111.           if (b->m_ctx != NULL) {
112.               if (!bn_mul_mont_fixed_top(b->Ai, b->Ai, b->Ai, b->m_ctx, ctx)
113.                   || !bn_mul_mont_fixed_top(b->A, b->A, b->A, b->m_ctx, ctx))
                           ^
114.                   goto err;
115.           } else {

crypto/bn/bn_mont.c:37:1: Parameter `ctx->pool.used`
  35.   }
  36.   
  37. > int bn_mul_mont_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
  38.                             BN_MONT_CTX *mont, BN_CTX *ctx)
  39.   {

crypto/bn/bn_mont.c:61:11: Call
  59.   
  60.       BN_CTX_start(ctx);
  61.       tmp = BN_CTX_get(ctx);
                  ^
  62.       if (tmp == NULL)
  63.           goto err;

crypto/bn/bn_ctx.c:204:1: Parameter `ctx->pool.used`
    202.   }
    203.   
    204. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
    205.   {
    206.       BIGNUM *ret;

crypto/bn/bn_mont.c:67:14: Call
  65.       bn_check_top(tmp);
  66.       if (a == b) {
  67.           if (!bn_sqr_fixed_top(tmp, a, ctx))
                     ^
  68.               goto err;
  69.       } else {

crypto/bn/bn_sqr.c:27:1: Parameter `ctx->pool.used`
    25.   }
    26.   
    27. > int bn_sqr_fixed_top(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
    28.   {
    29.       int max, al;

crypto/bn/bn_sqr.c:44:11: Call
    42.       BN_CTX_start(ctx);
    43.       rr = (a != r) ? r : BN_CTX_get(ctx);
    44.       tmp = BN_CTX_get(ctx);
                    ^
    45.       if (rr == NULL || tmp == NULL)
    46.           goto err;

crypto/bn/bn_ctx.c:204:1: Parameter `ctx->pool.used`
      202.   }
      203.   
      204. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
      205.   {
      206.       BIGNUM *ret;

crypto/bn/bn_sqr.c:104:5: Call
    102.       bn_check_top(rr);
    103.       bn_check_top(tmp);
    104.       BN_CTX_end(ctx);
               ^
    105.       return ret;
    106.   }

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

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

crypto/bn/bn_ctx.c:340:1: <LHS trace>
338.   }
339.   
340. > static void BN_POOL_release(BN_POOL *p, unsigned int num)
341.   {
342.       unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;

crypto/bn/bn_ctx.c:340:1: Parameter `p->used`
        338.   }
        339.   
        340. > static void BN_POOL_release(BN_POOL *p, unsigned int num)
        341.   {
        342.       unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;

crypto/bn/bn_ctx.c:342:5: Binary operation: ([0, +oo] - 1):unsigned32 by call to `bn_mul_mont_fixed_top` 
        340.   static void BN_POOL_release(BN_POOL *p, unsigned int num)
        341.   {
        342.       unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;
                   ^
        343.   
        344.       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_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx)\n{\n    int ret = 0;\n    if ((b->A == NULL) || (b->Ai == NULL)) {\n        BNerr(BN_F_BN_BLINDING_UPDATE, BN_R_NOT_INITIALIZED);\n        goto err;\n    }\n    if (b->counter == -1)\n        b->counter = 0;\n    if (++b->counter == BN_BLINDING_COUNTER && b->e != NULL &&\n        !(b->flags & BN_BLINDING_NO_RECREATE)) {\n        if (!BN_BLINDING_create_param(b, NULL, NULL, ctx, NULL, NULL))\n            goto err;\n    } else if (!(b->flags & BN_BLINDING_NO_UPDATE)) {\n        if (b->m_ctx != NULL) {\n            if (!bn_mul_mont_fixed_top(b->Ai, b->Ai, b->Ai, b->m_ctx, ctx)\n                || !bn_mul_mont_fixed_top(b->A, b->A, b->A, b->m_ctx, ctx))\n                goto err;\n        } else {\n            if (!BN_mod_mul(b->Ai, b->Ai, b->Ai, b->mod, ctx)\n                || !BN_mod_mul(b->A, b->A, b->A, b->mod, ctx))\n                goto err;\n        }\n    }\n    ret = 1;\n err:\n    if (b->counter == BN_BLINDING_COUNTER)\n        b->counter = 0;\n    return ret;\n}', 'int bn_mul_mont_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                          BN_MONT_CTX *mont, BN_CTX *ctx)\n{\n    BIGNUM *tmp;\n    int ret = 0;\n    int num = mont->N.top;\n#if defined(OPENSSL_BN_ASM_MONT) && defined(MONT_WORD)\n    if (num > 1 && a->top == num && b->top == num) {\n        if (bn_wexpand(r, num) == NULL)\n            return 0;\n        if (bn_mul_mont(r->d, a->d, b->d, mont->N.d, mont->n0, num)) {\n            r->neg = a->neg ^ b->neg;\n            r->top = num;\n            r->flags |= BN_FLG_FIXED_TOP;\n            return 1;\n        }\n    }\n#endif\n    if ((a->top + b->top) > 2 * num)\n        return 0;\n    BN_CTX_start(ctx);\n    tmp = BN_CTX_get(ctx);\n    if (tmp == NULL)\n        goto err;\n    bn_check_top(tmp);\n    if (a == b) {\n        if (!bn_sqr_fixed_top(tmp, a, ctx))\n            goto err;\n    } else {\n        if (!bn_mul_fixed_top(tmp, a, b, ctx))\n            goto err;\n    }\n#ifdef MONT_WORD\n    if (!bn_from_montgomery_word(r, tmp, mont))\n        goto err;\n#else\n    if (!BN_from_montgomery(r, tmp, mont, ctx))\n        goto err;\n#endif\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\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_sqr_fixed_top(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 == NULL || tmp == NULL)\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    rr->top = max;\n    rr->flags |= BN_FLG_FIXED_TOP;\n    if (r != rr && BN_copy(r, rr) == NULL)\n        goto err;\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    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}']