crypto/bn/bn_exp.c:243: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `BN_mod_mul_reciprocal`.
Showing all 23 steps of the trace


crypto/bn/bn_exp.c:161:1: Parameter `ctx->stack.depth`
159.   }
160.   
161. > int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
162.                       const BIGNUM *m, BN_CTX *ctx)
163.   {

crypto/bn/bn_exp.c:191:5: Call
189.       }
190.   
191.       BN_CTX_start(ctx);
           ^
192.       aa = BN_CTX_get(ctx);
193.       val[0] = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:181:1: Parameter `ctx->stack.depth`
  179.   }
  180.   
  181. > void BN_CTX_start(BN_CTX *ctx)
  182.   {
  183.       CTXDBG_ENTRY("BN_CTX_start", ctx);

crypto/bn/bn_exp.c:210:10: Call
208.       }
209.   
210.       if (!BN_nnmod(val[0], a, m, ctx))
                ^
211.           goto err;               /* 1 */
212.       if (BN_is_zero(val[0])) {

crypto/bn/bn_mod.c:13:1: Parameter `ctx->stack.depth`
  11.   #include "bn_lcl.h"
  12.   
  13. > int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
  14.   {
  15.       /*

crypto/bn/bn_mod.c:20:11: Call
  18.        */
  19.   
  20.       if (!(BN_mod(r, m, d, ctx)))
                  ^
  21.           return 0;
  22.       if (!r->neg)

crypto/bn/bn_div.c:209:1: Parameter `ctx->stack.depth`
    207.    * If 'dv' or 'rm' is NULL, the respective value is not returned.
    208.    */
    209. > int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
    210.              BN_CTX *ctx)
    211.   {

crypto/bn/bn_exp.c:243:22: Call
241.           if (BN_is_bit_set(p, wstart) == 0) {
242.               if (!start)
243.                   if (!BN_mod_mul_reciprocal(r, r, r, &recp, ctx))
                            ^
244.                       goto err;
245.               if (wstart == 0)

crypto/bn/bn_recp.c:55:1: Parameter `ctx->stack.depth`
  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:62:5: Call
  60.       const BIGNUM *ca;
  61.   
  62.       BN_CTX_start(ctx);
            ^
  63.       if ((a = BN_CTX_get(ctx)) == NULL)
  64.           goto err;

crypto/bn/bn_ctx.c:181:1: Parameter `ctx->stack.depth`
    179.   }
    180.   
    181. > void BN_CTX_start(BN_CTX *ctx)
    182.   {
    183.       CTXDBG_ENTRY("BN_CTX_start", ctx);

crypto/bn/bn_recp.c:67:18: Call
  65.       if (y != NULL) {
  66.           if (x == y) {
  67.               if (!BN_sqr(a, x, ctx))
                         ^
  68.                   goto err;
  69.           } else {

crypto/bn/bn_sqr.c:17:1: Parameter `ctx->stack.depth`
    15.    * I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96
    16.    */
    17. > int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
    18.   {
    19.       int ret = bn_sqr_fixed_top(r, a, ctx);

crypto/bn/bn_sqr.c:19:15: Call
    17.   int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
    18.   {
    19.       int ret = bn_sqr_fixed_top(r, a, ctx);
                        ^
    20.   
    21.       bn_correct_top(r);

crypto/bn/bn_sqr.c:27:1: Parameter `ctx->stack.depth`
      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:42:5: Call
      40.       }
      41.   
      42.       BN_CTX_start(ctx);
                ^
      43.       rr = (a != r) ? r : BN_CTX_get(ctx);
      44.       tmp = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:181:1: Parameter `ctx->stack.depth`
        179.   }
        180.   
        181. > void BN_CTX_start(BN_CTX *ctx)
        182.   {
        183.       CTXDBG_ENTRY("BN_CTX_start", ctx);

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:195:1: Parameter `ctx->stack.depth`
        193.   }
        194.   
        195. > void BN_CTX_end(BN_CTX *ctx)
        196.   {
        197.       CTXDBG_ENTRY("BN_CTX_end", ctx);

crypto/bn/bn_ctx.c:201:27: Call
        199.           ctx->err_stack--;
        200.       else {
        201.           unsigned int fp = BN_STACK_pop(&ctx->stack);
                                         ^
        202.           /* Does this stack frame have anything to release? */
        203.           if (fp < ctx->used)

crypto/bn/bn_ctx.c:274:1: <LHS trace>
272.   }
273.   
274. > static unsigned int BN_STACK_pop(BN_STACK *st)
275.   {
276.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:274:1: Parameter `st->depth`
          272.   }
          273.   
          274. > static unsigned int BN_STACK_pop(BN_STACK *st)
          275.   {
          276.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:276:12: Binary operation: ([0, +oo] - 1):unsigned32 by call to `BN_mod_mul_reciprocal` 
          274.   static unsigned int BN_STACK_pop(BN_STACK *st)
          275.   {
          276.       return st->indexes[--(st->depth)];
                            ^
          277.   }
          278.   

static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                    const BIGNUM *m, BN_CTX *ctx)\n{\n    int i, j, bits, ret = 0, wstart, wend, window, wvalue;\n    int start = 1;\n    BIGNUM *aa;\n    BIGNUM *val[TABLE_SIZE];\n    BN_RECP_CTX recp;\n    if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0\n            || BN_get_flags(a, BN_FLG_CONSTTIME) != 0\n            || BN_get_flags(m, BN_FLG_CONSTTIME) != 0) {\n        BNerr(BN_F_BN_MOD_EXP_RECP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    bits = BN_num_bits(p);\n    if (bits == 0) {\n        if (BN_abs_is_word(m, 1)) {\n            ret = 1;\n            BN_zero(r);\n        } else {\n            ret = BN_one(r);\n        }\n        return ret;\n    }\n    BN_CTX_start(ctx);\n    aa = BN_CTX_get(ctx);\n    val[0] = BN_CTX_get(ctx);\n    if (val[0] == NULL)\n        goto err;\n    BN_RECP_CTX_init(&recp);\n    if (m->neg) {\n        if (!BN_copy(aa, m))\n            goto err;\n        aa->neg = 0;\n        if (BN_RECP_CTX_set(&recp, aa, ctx) <= 0)\n            goto err;\n    } else {\n        if (BN_RECP_CTX_set(&recp, m, ctx) <= 0)\n            goto err;\n    }\n    if (!BN_nnmod(val[0], a, m, ctx))\n        goto err;\n    if (BN_is_zero(val[0])) {\n        BN_zero(r);\n        ret = 1;\n        goto err;\n    }\n    window = BN_window_bits_for_exponent_size(bits);\n    if (window > 1) {\n        if (!BN_mod_mul_reciprocal(aa, val[0], val[0], &recp, ctx))\n            goto err;\n        j = 1 << (window - 1);\n        for (i = 1; i < j; i++) {\n            if (((val[i] = BN_CTX_get(ctx)) == NULL) ||\n                !BN_mod_mul_reciprocal(val[i], val[i - 1], aa, &recp, ctx))\n                goto err;\n        }\n    }\n    start = 1;\n    wvalue = 0;\n    wstart = bits - 1;\n    wend = 0;\n    if (!BN_one(r))\n        goto err;\n    for (;;) {\n        if (BN_is_bit_set(p, wstart) == 0) {\n            if (!start)\n                if (!BN_mod_mul_reciprocal(r, r, r, &recp, ctx))\n                    goto err;\n            if (wstart == 0)\n                break;\n            wstart--;\n            continue;\n        }\n        j = wstart;\n        wvalue = 1;\n        wend = 0;\n        for (i = 1; i < window; i++) {\n            if (wstart - i < 0)\n                break;\n            if (BN_is_bit_set(p, wstart - i)) {\n                wvalue <<= (i - wend);\n                wvalue |= 1;\n                wend = i;\n            }\n        }\n        j = wend + 1;\n        if (!start)\n            for (i = 0; i < j; i++) {\n                if (!BN_mod_mul_reciprocal(r, r, r, &recp, ctx))\n                    goto err;\n            }\n        if (!BN_mod_mul_reciprocal(r, r, val[wvalue >> 1], &recp, ctx))\n            goto err;\n        wstart -= wend + 1;\n        wvalue = 0;\n        start = 0;\n        if (wstart < 0)\n            break;\n    }\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    BN_RECP_CTX_free(&recp);\n    bn_check_top(r);\n    return ret;\n}', 'void BN_CTX_start(BN_CTX *ctx)\n{\n    CTXDBG_ENTRY("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_EXIT(ctx);\n}', 'int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)\n{\n    if (!(BN_mod(r, m, d, ctx)))\n        return 0;\n    if (!r->neg)\n        return 1;\n    return (d->neg ? BN_sub : BN_add) (r, r, d);\n}', 'int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,\n           BN_CTX *ctx)\n{\n    int ret;\n    if (BN_is_zero(divisor)) {\n        BNerr(BN_F_BN_DIV, BN_R_DIV_BY_ZERO);\n        return 0;\n    }\n    if (divisor->d[divisor->top - 1] == 0) {\n        BNerr(BN_F_BN_DIV, BN_R_NOT_INITIALIZED);\n        return 0;\n    }\n    ret = bn_div_fixed_top(dv, rm, num, divisor, ctx);\n    if (ret) {\n        if (dv != NULL)\n            bn_correct_top(dv);\n        if (rm != NULL)\n            bn_correct_top(rm);\n    }\n    return ret;\n}', '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}', 'int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)\n{\n    int ret = bn_sqr_fixed_top(r, a, ctx);\n    bn_correct_top(r);\n    bn_check_top(r);\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    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 unsigned int BN_STACK_pop(BN_STACK *st)\n{\n    return st->indexes[--(st->depth)];\n}']