test/ec_internal_test.c:174: error: BUFFER_OVERRUN_L3
  Offset: [-1, +oo] Size: [1, +oo] by call to `group_field_tests`.
Showing all 11 steps of the trace


test/ec_internal_test.c:174:13: Call
172.       if (!TEST_ptr(group = EC_GROUP_new_by_curve_name(nid))
173.           || !TEST_ptr(ctx = BN_CTX_new())
174.           || !group_field_tests(group, ctx))
                   ^
175.           goto err;
176.   

test/ec_internal_test.c:28:5: Call
  26.           return 1;
  27.   
  28.       BN_CTX_start(ctx);
            ^
  29.       a = BN_CTX_get(ctx);
  30.       b = BN_CTX_get(ctx);

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

test/ec_internal_test.c:65:5: Call
  63.       ret = 1;
  64.    err:
  65.       BN_CTX_end(ctx);
            ^
  66.       return ret;
  67.   }

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:274:1: <Offset 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:274:1: <Length 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->indexes`
      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: Array access: Offset: [-1, +oo] Size: [1, +oo] by call to `group_field_tests` 
      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)];
}
['static int field_tests_default(int n)\n{\n    BN_CTX *ctx = NULL;\n    EC_GROUP *group = NULL;\n    int nid = curves[n].nid;\n    int ret = 0;\n    TEST_info("Testing curve %s\\n", OBJ_nid2sn(nid));\n    if (!TEST_ptr(group = EC_GROUP_new_by_curve_name(nid))\n        || !TEST_ptr(ctx = BN_CTX_new())\n        || !group_field_tests(group, ctx))\n        goto err;\n    ret = 1;\n err:\n    if (group != NULL)\n        EC_GROUP_free(group);\n    if (ctx != NULL)\n        BN_CTX_free(ctx);\n    return ret;\n}', 'static int group_field_tests(const EC_GROUP *group, BN_CTX *ctx)\n{\n    BIGNUM *a = NULL, *b = NULL, *c = NULL;\n    int ret = 0;\n    if (group->meth->field_inv == NULL || group->meth->field_mul == NULL)\n        return 1;\n    BN_CTX_start(ctx);\n    a = BN_CTX_get(ctx);\n    b = BN_CTX_get(ctx);\n    if (!TEST_ptr(c = BN_CTX_get(ctx))\n        || !TEST_true(group->meth->field_inv(group, b, BN_value_one(), ctx))\n        || !TEST_true(BN_is_one(b))\n        || !TEST_true(BN_pseudo_rand(a, BN_num_bits(group->field) - 1,\n                                     BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY))\n        || !TEST_true(group->meth->field_inv(group, b, a, ctx))\n        || (group->meth->field_encode &&\n            !TEST_true(group->meth->field_encode(group, a, a, ctx)))\n        || (group->meth->field_encode &&\n            !TEST_true(group->meth->field_encode(group, b, b, ctx)))\n        || !TEST_true(group->meth->field_mul(group, c, a, b, ctx))\n        || (group->meth->field_decode &&\n            !TEST_true(group->meth->field_decode(group, c, c, ctx)))\n        || !TEST_true(BN_is_one(c)))\n        goto err;\n    BN_zero(a);\n    if (!TEST_false(group->meth->field_inv(group, b, a, ctx))\n        || !TEST_true(ERR_GET_LIB(ERR_peek_last_error()) == ERR_LIB_EC)\n        || !TEST_true(ERR_GET_REASON(ERR_peek_last_error()) ==\n                      EC_R_CANNOT_INVERT)\n        || !TEST_false(group->meth->field_inv(group, b, group->field, ctx))\n        || !TEST_true(ERR_GET_LIB(ERR_peek_last_error()) == ERR_LIB_EC)\n        || !TEST_true(ERR_GET_REASON(ERR_peek_last_error()) ==\n                      EC_R_CANNOT_INVERT))\n        goto err;\n    ERR_clear_error();\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}', 'static unsigned int BN_STACK_pop(BN_STACK *st)\n{\n    return st->indexes[--(st->depth)];\n}']