crypto/rsa/rsa_crpt.c:132: error: BUFFER_OVERRUN_L3
  Offset: [-1, +oo] Size: [1, +oo] by call to `rsa_get_public_exp`.
Showing all 18 steps of the trace


crypto/rsa/rsa_crpt.c:111:1: Parameter `in_ctx->stack.depth`
109.   }
110.   
111. > BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *in_ctx)
112.   {
113.       BIGNUM *e;

crypto/rsa/rsa_crpt.c:124:5: Call
122.       }
123.   
124.       BN_CTX_start(ctx);
           ^
125.       e = BN_CTX_get(ctx);
126.       if (e == 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/rsa/rsa_crpt.c:132:13: Call
130.   
131.       if (rsa->e == NULL) {
132.           e = rsa_get_public_exp(rsa->d, rsa->p, rsa->q, ctx);
                   ^
133.           if (e == NULL) {
134.               RSAerr(RSA_F_RSA_SETUP_BLINDING, RSA_R_NO_PUBLIC_EXPONENT);

crypto/rsa/rsa_crpt.c:83:1: Parameter `ctx->stack.depth`
  81.   }
  82.   
  83. > static BIGNUM *rsa_get_public_exp(const BIGNUM *d, const BIGNUM *p,
  84.                                     const BIGNUM *q, BN_CTX *ctx)
  85.   {

crypto/rsa/rsa_crpt.c:91:5: Call
  89.           return NULL;
  90.   
  91.       BN_CTX_start(ctx);
            ^
  92.       r0 = BN_CTX_get(ctx);
  93.       r1 = 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/rsa/rsa_crpt.c:102:10: Call
  100.       if (!BN_sub(r2, q, BN_value_one()))
  101.           goto err;
  102.       if (!BN_mul(r0, r1, r2, ctx))
                  ^
  103.           goto err;
  104.   

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.indexes`
      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.indexes`
      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: <Offset 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:271:1: <Length 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->indexes`
        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: Array access: Offset: [-1, +oo] Size: [1, +oo] by call to `rsa_get_public_exp` 
        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)];
}
['BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *in_ctx)\n{\n    BIGNUM *e;\n    BN_CTX *ctx;\n    BN_BLINDING *ret = NULL;\n    if (in_ctx == NULL) {\n        if ((ctx = BN_CTX_new()) == NULL)\n            return 0;\n    } else {\n        ctx = in_ctx;\n    }\n    BN_CTX_start(ctx);\n    e = BN_CTX_get(ctx);\n    if (e == NULL) {\n        RSAerr(RSA_F_RSA_SETUP_BLINDING, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    if (rsa->e == NULL) {\n        e = rsa_get_public_exp(rsa->d, rsa->p, rsa->q, ctx);\n        if (e == NULL) {\n            RSAerr(RSA_F_RSA_SETUP_BLINDING, RSA_R_NO_PUBLIC_EXPONENT);\n            goto err;\n        }\n    } else {\n        e = rsa->e;\n    }\n    {\n        BIGNUM *n = BN_new();\n        if (n == NULL) {\n            RSAerr(RSA_F_RSA_SETUP_BLINDING, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n        BN_with_flags(n, rsa->n, BN_FLG_CONSTTIME);\n        ret = BN_BLINDING_create_param(NULL, e, n, ctx, rsa->meth->bn_mod_exp,\n                                       rsa->_method_mod_n);\n        BN_free(n);\n    }\n    if (ret == NULL) {\n        RSAerr(RSA_F_RSA_SETUP_BLINDING, ERR_R_BN_LIB);\n        goto err;\n    }\n    BN_BLINDING_set_current_thread(ret);\n err:\n    BN_CTX_end(ctx);\n    if (ctx != in_ctx)\n        BN_CTX_free(ctx);\n    if (e != rsa->e)\n        BN_free(e);\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 BIGNUM *rsa_get_public_exp(const BIGNUM *d, const BIGNUM *p,\n                                  const BIGNUM *q, BN_CTX *ctx)\n{\n    BIGNUM *ret = NULL, *r0, *r1, *r2;\n    if (d == NULL || p == NULL || q == NULL)\n        return NULL;\n    BN_CTX_start(ctx);\n    r0 = BN_CTX_get(ctx);\n    r1 = BN_CTX_get(ctx);\n    r2 = BN_CTX_get(ctx);\n    if (r2 == NULL)\n        goto err;\n    if (!BN_sub(r1, p, BN_value_one()))\n        goto err;\n    if (!BN_sub(r2, q, BN_value_one()))\n        goto err;\n    if (!BN_mul(r0, r1, r2, ctx))\n        goto err;\n    ret = BN_mod_inverse(NULL, d, r0, ctx);\n err:\n    BN_CTX_end(ctx);\n    return ret;\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}']