test/bntest.c:680: error: BUFFER_OVERRUN_L3
  Offset: [-1, +oo] Size: [1, +oo] by call to `BN_GF2m_mod_div`.
Showing all 25 steps of the trace


test/bntest.c:680:13: Call
678.           BN_bntest_rand(c, 512, 0, 0);
679.           for (j = 0; j < 2; j++) {
680.               BN_GF2m_mod_div(d, a, c, b[j], ctx);
                   ^
681.               BN_GF2m_mod_mul(e, d, c, b[j], ctx);
682.               BN_GF2m_mod_div(f, a, e, b[j], ctx);

crypto/bn/bn_gf2m.c:760:1: Parameter `ctx->stack.depth`
  758.    * or y, x could equal y.
  759.    */
  760. > int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *y, const BIGNUM *x,
  761.                       const BIGNUM *p, BN_CTX *ctx)
  762.   {

crypto/bn/bn_gf2m.c:770:5: Call
  768.       bn_check_top(p);
  769.   
  770.       BN_CTX_start(ctx);
             ^
  771.       xinv = BN_CTX_get(ctx);
  772.       if (xinv == 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_gf2m.c:783:5: Call
  781.   
  782.    err:
  783.       BN_CTX_end(ctx);
             ^
  784.       return ret;
  785.   }

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);

test/bntest.c:681:13: Call
679.           for (j = 0; j < 2; j++) {
680.               BN_GF2m_mod_div(d, a, c, b[j], ctx);
681.               BN_GF2m_mod_mul(e, d, c, b[j], ctx);
                   ^
682.               BN_GF2m_mod_div(f, a, e, b[j], ctx);
683.               /* Test that ((a/c)*c)/a = 1. */

crypto/bn/bn_gf2m.c:473:1: Parameter `ctx->stack.depth`
  471.    * BN_GF2m_mod_mul_arr function.
  472.    */
  473. > int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
  474.                       const BIGNUM *p, BN_CTX *ctx)
  475.   {

test/bntest.c:682:13: Call
680.               BN_GF2m_mod_div(d, a, c, b[j], ctx);
681.               BN_GF2m_mod_mul(e, d, c, b[j], ctx);
682.               BN_GF2m_mod_div(f, a, e, b[j], ctx);
                   ^
683.               /* Test that ((a/c)*c)/a = 1. */
684.               if (!TEST_true(BN_is_one(f)))

crypto/bn/bn_gf2m.c:760:1: Parameter `ctx->stack.depth`
  758.    * or y, x could equal y.
  759.    */
  760. > int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *y, const BIGNUM *x,
  761.                       const BIGNUM *p, BN_CTX *ctx)
  762.   {

crypto/bn/bn_gf2m.c:770:5: Call
  768.       bn_check_top(p);
  769.   
  770.       BN_CTX_start(ctx);
             ^
  771.       xinv = BN_CTX_get(ctx);
  772.       if (xinv == 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_gf2m.c:783:5: Call
  781.   
  782.    err:
  783.       BN_CTX_end(ctx);
             ^
  784.       return ret;
  785.   }

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);

test/bntest.c:680:13: Call
678.           BN_bntest_rand(c, 512, 0, 0);
679.           for (j = 0; j < 2; j++) {
680.               BN_GF2m_mod_div(d, a, c, b[j], ctx);
                   ^
681.               BN_GF2m_mod_mul(e, d, c, b[j], ctx);
682.               BN_GF2m_mod_div(f, a, e, b[j], ctx);

crypto/bn/bn_gf2m.c:770:5: Call
  768.       bn_check_top(p);
  769.   
  770.       BN_CTX_start(ctx);
             ^
  771.       xinv = BN_CTX_get(ctx);
  772.       if (xinv == 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_gf2m.c:783:5: Call
  781.   
  782.    err:
  783.       BN_CTX_end(ctx);
             ^
  784.       return ret;
  785.   }

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 `BN_GF2m_mod_div` 
      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)];
}
['static int test_gf2m_moddiv()\n{\n    BIGNUM *a = NULL, *b[2] = {NULL,NULL}, *c = NULL, *d = NULL;\n    BIGNUM *e = NULL, *f = NULL;\n    int i, j, st = 0;\n    if (!TEST_ptr(a = BN_new())\n            || !TEST_ptr(b[0] = BN_new())\n            || !TEST_ptr(b[1] = BN_new())\n            || !TEST_ptr(c = BN_new())\n            || !TEST_ptr(d = BN_new())\n            || !TEST_ptr(e = BN_new())\n            || !TEST_ptr(f = BN_new()))\n        goto err;\n    BN_GF2m_arr2poly(p0, b[0]);\n    BN_GF2m_arr2poly(p1, b[1]);\n    for (i = 0; i < NUM0; i++) {\n        BN_bntest_rand(a, 512, 0, 0);\n        BN_bntest_rand(c, 512, 0, 0);\n        for (j = 0; j < 2; j++) {\n            BN_GF2m_mod_div(d, a, c, b[j], ctx);\n            BN_GF2m_mod_mul(e, d, c, b[j], ctx);\n            BN_GF2m_mod_div(f, a, e, b[j], ctx);\n            if (!TEST_true(BN_is_one(f)))\n                goto err;\n        }\n    }\n    st = 1;\n err:\n    BN_free(a);\n    BN_free(b[0]);\n    BN_free(b[1]);\n    BN_free(c);\n    BN_free(d);\n    BN_free(e);\n    BN_free(f);\n    return st;\n}', 'int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *y, const BIGNUM *x,\n                    const BIGNUM *p, BN_CTX *ctx)\n{\n    BIGNUM *xinv = NULL;\n    int ret = 0;\n    bn_check_top(y);\n    bn_check_top(x);\n    bn_check_top(p);\n    BN_CTX_start(ctx);\n    xinv = BN_CTX_get(ctx);\n    if (xinv == NULL)\n        goto err;\n    if (!BN_GF2m_mod_inv(xinv, x, p, ctx))\n        goto err;\n    if (!BN_GF2m_mod_mul(r, y, xinv, p, ctx))\n        goto err;\n    bn_check_top(r);\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}', '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}', 'int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                    const BIGNUM *p, BN_CTX *ctx)\n{\n    int ret = 0;\n    const int max = BN_num_bits(p) + 1;\n    int *arr = NULL;\n    bn_check_top(a);\n    bn_check_top(b);\n    bn_check_top(p);\n    if ((arr = OPENSSL_malloc(sizeof(*arr) * max)) == NULL)\n        goto err;\n    ret = BN_GF2m_poly2arr(p, arr, max);\n    if (!ret || ret > max) {\n        BNerr(BN_F_BN_GF2M_MOD_MUL, BN_R_INVALID_LENGTH);\n        goto err;\n    }\n    ret = BN_GF2m_mod_mul_arr(r, a, b, arr, ctx);\n    bn_check_top(r);\n err:\n    OPENSSL_free(arr);\n    return ret;\n}', 'static unsigned int BN_STACK_pop(BN_STACK *st)\n{\n    return st->indexes[--(st->depth)];\n}']