crypto/bn/bn_x931p.c:86: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `BN_mul`.
Showing all 17 steps of the trace


crypto/bn/bn_x931p.c:51:1: Parameter `ctx->stack.depth`
49.    */
50.   
51. > int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
52.                               const BIGNUM *Xp, const BIGNUM *Xp1,
53.                               const BIGNUM *Xp2, const BIGNUM *e, BN_CTX *ctx,

crypto/bn/bn_x931p.c:64:5: Call
62.           return 0;
63.   
64.       BN_CTX_start(ctx);
          ^
65.       if (p1 == NULL)
66.           p1 = 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_x931p.c:80:10: Call
78.           goto err;
79.   
80.       if (!bn_x931_derive_pi(p1, Xp1, ctx, cb))
               ^
81.           goto err;
82.   

crypto/bn/bn_x931p.c:21:1: Parameter `ctx->stack.depth`
  19.    */
  20.   
  21. > static int bn_x931_derive_pi(BIGNUM *pi, const BIGNUM *Xpi, BN_CTX *ctx,
  22.                                BN_GENCB *cb)
  23.   {

crypto/bn/bn_x931p.c:83:10: Call
81.           goto err;
82.   
83.       if (!bn_x931_derive_pi(p2, Xp2, ctx, cb))
               ^
84.           goto err;
85.   

crypto/bn/bn_x931p.c:21:1: Parameter `ctx->stack.depth`
  19.    */
  20.   
  21. > static int bn_x931_derive_pi(BIGNUM *pi, const BIGNUM *Xpi, BN_CTX *ctx,
  22.                                BN_GENCB *cb)
  23.   {

crypto/bn/bn_x931p.c:86:10: Call
84.           goto err;
85.   
86.       if (!BN_mul(p1p2, p1, p2, ctx))
               ^
87.           goto err;
88.   

crypto/bn/bn_mul.c:497:1: Parameter `ctx->stack.depth`
  495.   #endif                          /* BN_RECURSION */
  496.   
  497. > int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
  498.   {
  499.       int ret = 0;

crypto/bn/bn_mul.c:523:5: Call
  521.       top = al + bl;
  522.   
  523.       BN_CTX_start(ctx);
             ^
  524.       if ((r == a) || (r == b)) {
  525.           if ((rr = BN_CTX_get(ctx)) == NULL)

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_mul.c:608:5: Call
  606.    err:
  607.       bn_check_top(r);
  608.       BN_CTX_end(ctx);
             ^
  609.       return ret;
  610.   }

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:271:1: <LHS trace>
269.   }
270.   
271. > static unsigned int BN_STACK_pop(BN_STACK *st)
272.   {
273.       return st->indexes[--(st->depth)];

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

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

static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,\n                            const BIGNUM *Xp, const BIGNUM *Xp1,\n                            const BIGNUM *Xp2, const BIGNUM *e, BN_CTX *ctx,\n                            BN_GENCB *cb)\n{\n    int ret = 0;\n    BIGNUM *t, *p1p2, *pm1;\n    if (!BN_is_odd(e))\n        return 0;\n    BN_CTX_start(ctx);\n    if (p1 == NULL)\n        p1 = BN_CTX_get(ctx);\n    if (p2 == NULL)\n        p2 = BN_CTX_get(ctx);\n    t = BN_CTX_get(ctx);\n    p1p2 = BN_CTX_get(ctx);\n    pm1 = BN_CTX_get(ctx);\n    if (pm1 == NULL)\n        goto err;\n    if (!bn_x931_derive_pi(p1, Xp1, ctx, cb))\n        goto err;\n    if (!bn_x931_derive_pi(p2, Xp2, ctx, cb))\n        goto err;\n    if (!BN_mul(p1p2, p1, p2, ctx))\n        goto err;\n    if (!BN_mod_inverse(p, p2, p1, ctx))\n        goto err;\n    if (!BN_mul(p, p, p2, ctx))\n        goto err;\n    if (!BN_mod_inverse(t, p1, p2, ctx))\n        goto err;\n    if (!BN_mul(t, t, p1, ctx))\n        goto err;\n    if (!BN_sub(p, p, t))\n        goto err;\n    if (p->neg && !BN_add(p, p, p1p2))\n        goto err;\n    if (!BN_mod_sub(p, p, Xp, p1p2, ctx))\n        goto err;\n    if (!BN_add(p, p, Xp))\n        goto err;\n    for (;;) {\n        int i = 1;\n        BN_GENCB_call(cb, 0, i++);\n        if (!BN_copy(pm1, p))\n            goto err;\n        if (!BN_sub_word(pm1, 1))\n            goto err;\n        if (!BN_gcd(t, pm1, e, ctx))\n            goto err;\n        if (BN_is_one(t)) {\n            int r = BN_is_prime_fasttest_ex(p, 50, ctx, 1, cb);\n            if (r < 0)\n                goto err;\n            if (r)\n                break;\n        }\n        if (!BN_add(p, p, p1p2))\n            goto err;\n    }\n    BN_GENCB_call(cb, 3, 0);\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\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}', 'static int bn_x931_derive_pi(BIGNUM *pi, const BIGNUM *Xpi, BN_CTX *ctx,\n                             BN_GENCB *cb)\n{\n    int i = 0, is_prime;\n    if (!BN_copy(pi, Xpi))\n        return 0;\n    if (!BN_is_odd(pi) && !BN_add_word(pi, 1))\n        return 0;\n    for (;;) {\n        i++;\n        BN_GENCB_call(cb, 0, i);\n        is_prime = BN_is_prime_fasttest_ex(pi, 27, ctx, 1, cb);\n        if (is_prime < 0)\n            return 0;\n        if (is_prime)\n            break;\n        if (!BN_add_word(pi, 2))\n            return 0;\n    }\n    BN_GENCB_call(cb, 2, i);\n    return 1;\n}', 'int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)\n{\n    int ret = 0;\n    int top, al, bl;\n    BIGNUM *rr;\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\n    int i;\n#endif\n#ifdef BN_RECURSION\n    BIGNUM *t = NULL;\n    int j = 0, k;\n#endif\n    bn_check_top(a);\n    bn_check_top(b);\n    bn_check_top(r);\n    al = a->top;\n    bl = b->top;\n    if ((al == 0) || (bl == 0)) {\n        BN_zero(r);\n        return 1;\n    }\n    top = al + bl;\n    BN_CTX_start(ctx);\n    if ((r == a) || (r == b)) {\n        if ((rr = BN_CTX_get(ctx)) == NULL)\n            goto err;\n    } else\n        rr = r;\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\n    i = al - bl;\n#endif\n#ifdef BN_MUL_COMBA\n    if (i == 0) {\n# if 0\n        if (al == 4) {\n            if (bn_wexpand(rr, 8) == NULL)\n                goto err;\n            rr->top = 8;\n            bn_mul_comba4(rr->d, a->d, b->d);\n            goto end;\n        }\n# endif\n        if (al == 8) {\n            if (bn_wexpand(rr, 16) == NULL)\n                goto err;\n            rr->top = 16;\n            bn_mul_comba8(rr->d, a->d, b->d);\n            goto end;\n        }\n    }\n#endif\n#ifdef BN_RECURSION\n    if ((al >= BN_MULL_SIZE_NORMAL) && (bl >= BN_MULL_SIZE_NORMAL)) {\n        if (i >= -1 && i <= 1) {\n            if (i >= 0) {\n                j = BN_num_bits_word((BN_ULONG)al);\n            }\n            if (i == -1) {\n                j = BN_num_bits_word((BN_ULONG)bl);\n            }\n            j = 1 << (j - 1);\n            assert(j <= al || j <= bl);\n            k = j + j;\n            t = BN_CTX_get(ctx);\n            if (t == NULL)\n                goto err;\n            if (al > j || bl > j) {\n                if (bn_wexpand(t, k * 4) == NULL)\n                    goto err;\n                if (bn_wexpand(rr, k * 4) == NULL)\n                    goto err;\n                bn_mul_part_recursive(rr->d, a->d, b->d,\n                                      j, al - j, bl - j, t->d);\n            } else {\n                if (bn_wexpand(t, k * 2) == NULL)\n                    goto err;\n                if (bn_wexpand(rr, k * 2) == NULL)\n                    goto err;\n                bn_mul_recursive(rr->d, a->d, b->d, j, al - j, bl - j, t->d);\n            }\n            rr->top = top;\n            goto end;\n        }\n    }\n#endif\n    if (bn_wexpand(rr, top) == NULL)\n        goto err;\n    rr->top = top;\n    bn_mul_normal(rr->d, a->d, al, b->d, bl);\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\n end:\n#endif\n    rr->neg = a->neg ^ b->neg;\n    bn_correct_top(rr);\n    if (r != rr && BN_copy(r, rr) == NULL)\n        goto err;\n    ret = 1;\n err:\n    bn_check_top(r);\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}']