crypto/rsa/rsa_x931g.c:76: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `BN_CTX_end`.
Showing all 8 steps of the trace


crypto/rsa/rsa_x931g.c:34:5: Call
32.       if (ctx == NULL)
33.           goto err;
34.       BN_CTX_start(ctx);
          ^
35.   
36.       r0 = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:171:1: Parameter `ctx->stack.depth`
  169.   }
  170.   
  171. > void BN_CTX_start(BN_CTX *ctx)
  172.   {
  173.       CTXDBG("ENTER BN_CTX_start()", ctx);

crypto/rsa/rsa_x931g.c:76:9: Call
74.   
75.       if (rsa->p == NULL || rsa->q == NULL) {
76.           BN_CTX_end(ctx);
              ^
77.           BN_CTX_free(ctx);
78.           return 2;

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

crypto/bn/bn_ctx.c:193:27: Call
  191.           ctx->err_stack--;
  192.       else {
  193.           unsigned int fp = BN_STACK_pop(&ctx->stack);
                                   ^
  194.           /* Does this stack frame have anything to release? */
  195.           if (fp < ctx->used)

crypto/bn/bn_ctx.c:268:1: <LHS trace>
266.   }
267.   
268. > static unsigned int BN_STACK_pop(BN_STACK *st)
269.   {
270.       return st->indexes[--(st->depth)];

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

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

static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['int RSA_X931_derive_ex(RSA *rsa, BIGNUM *p1, BIGNUM *p2, BIGNUM *q1,\n                       BIGNUM *q2, const BIGNUM *Xp1, const BIGNUM *Xp2,\n                       const BIGNUM *Xp, const BIGNUM *Xq1, const BIGNUM *Xq2,\n                       const BIGNUM *Xq, const BIGNUM *e, BN_GENCB *cb)\n{\n    BIGNUM *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL;\n    BN_CTX *ctx = NULL, *ctx2 = NULL;\n    int ret = 0;\n    if (!rsa)\n        goto err;\n    ctx = BN_CTX_new();\n    if (ctx == NULL)\n        goto err;\n    BN_CTX_start(ctx);\n    r0 = BN_CTX_get(ctx);\n    r1 = BN_CTX_get(ctx);\n    r2 = BN_CTX_get(ctx);\n    r3 = BN_CTX_get(ctx);\n    if (r3 == NULL)\n        goto err;\n    if (!rsa->e) {\n        rsa->e = BN_dup(e);\n        if (!rsa->e)\n            goto err;\n    } else {\n        e = rsa->e;\n    }\n    if (Xp && rsa->p == NULL) {\n        rsa->p = BN_new();\n        if (rsa->p == NULL)\n            goto err;\n        if (!BN_X931_derive_prime_ex(rsa->p, p1, p2,\n                                     Xp, Xp1, Xp2, e, ctx, cb))\n            goto err;\n    }\n    if (Xq && rsa->q == NULL) {\n        rsa->q = BN_new();\n        if (rsa->q == NULL)\n            goto err;\n        if (!BN_X931_derive_prime_ex(rsa->q, q1, q2,\n                                     Xq, Xq1, Xq2, e, ctx, cb))\n            goto err;\n    }\n    if (rsa->p == NULL || rsa->q == NULL) {\n        BN_CTX_end(ctx);\n        BN_CTX_free(ctx);\n        return 2;\n    }\n    rsa->n = BN_new();\n    if (rsa->n == NULL)\n        goto err;\n    if (!BN_mul(rsa->n, rsa->p, rsa->q, ctx))\n        goto err;\n    if (!BN_sub(r1, rsa->p, BN_value_one()))\n        goto err;\n    if (!BN_sub(r2, rsa->q, BN_value_one()))\n        goto err;\n    if (!BN_mul(r0, r1, r2, ctx))\n        goto err;\n    if (!BN_gcd(r3, r1, r2, ctx))\n        goto err;\n    if (!BN_div(r0, NULL, r0, r3, ctx))\n        goto err;\n    ctx2 = BN_CTX_new();\n    if (ctx2 == NULL)\n        goto err;\n    rsa->d = BN_mod_inverse(NULL, rsa->e, r0, ctx2);\n    if (rsa->d == NULL)\n        goto err;\n    rsa->dmp1 = BN_new();\n    if (rsa->dmp1 == NULL)\n        goto err;\n    if (!BN_mod(rsa->dmp1, rsa->d, r1, ctx))\n        goto err;\n    rsa->dmq1 = BN_new();\n    if (rsa->dmq1 == NULL)\n        goto err;\n    if (!BN_mod(rsa->dmq1, rsa->d, r2, ctx))\n        goto err;\n    rsa->iqmp = BN_mod_inverse(NULL, rsa->q, rsa->p, ctx2);\n    if (rsa->iqmp == NULL)\n        goto err;\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(ctx);\n    BN_CTX_free(ctx2);\n    return ret;\n}', 'void BN_CTX_start(BN_CTX *ctx)\n{\n    CTXDBG("ENTER 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("LEAVE BN_CTX_start()", ctx);\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 unsigned int BN_STACK_pop(BN_STACK *st)\n{\n    return st->indexes[--(st->depth)];\n}']