test/bntest.c:1613: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `BN_GF2m_mod_sqr`.
Showing all 15 steps of the trace


test/bntest.c:1590:1: Parameter `ctx->stack.depth`
1588.   }
1589.   
1590. > int test_gf2m_mod_solve_quad(BIO *bp, BN_CTX *ctx)
1591.   {
1592.       BIGNUM *a, *b[2], *c, *d, *e;

test/bntest.c:1610:17: Call
1608.           BN_bntest_rand(a, 512, 0, 0);
1609.           for (j = 0; j < 2; j++) {
1610.               t = BN_GF2m_mod_solve_quad(c, a, b[j], ctx);
                        ^
1611.               if (t) {
1612.                   s++;

crypto/bn/bn_gf2m.c:1145:1: Parameter `ctx->stack.depth`
  1143.    * for best performance, use the BN_GF2m_mod_solve_quad_arr function.
  1144.    */
  1145. > int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
  1146.                              BN_CTX *ctx)
  1147.   {

test/bntest.c:1613:17: Call
1611.               if (t) {
1612.                   s++;
1613.                   BN_GF2m_mod_sqr(d, c, b[j], ctx);
                        ^
1614.                   BN_GF2m_add(d, c, d);
1615.                   BN_GF2m_mod(e, a, b[j]);

crypto/bn/bn_gf2m.c:532:1: Parameter `ctx->stack.depth`
  530.    * use the BN_GF2m_mod_sqr_arr function.
  531.    */
  532. > int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
  533.   {
  534.       int ret = 0;

crypto/bn/bn_gf2m.c:547:11: Call
  545.           goto err;
  546.       }
  547.       ret = BN_GF2m_mod_sqr_arr(r, a, arr, ctx);
                   ^
  548.       bn_check_top(r);
  549.    err:

crypto/bn/bn_gf2m.c:497:1: Parameter `ctx->stack.depth`
    495.   
    496.   /* Square a, reduce the result mod p, and store it in a.  r could be a. */
    497. > int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[],
    498.                           BN_CTX *ctx)
    499.   {

crypto/bn/bn_gf2m.c:504:5: Call
    502.   
    503.       bn_check_top(a);
    504.       BN_CTX_start(ctx);
               ^
    505.       if ((s = BN_CTX_get(ctx)) == NULL)
    506.           goto err;

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:522:5: Call
    520.       ret = 1;
    521.    err:
    522.       BN_CTX_end(ctx);
               ^
    523.       return ret;
    524.   }

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_GF2m_mod_sqr` 
        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 test_gf2m_mod_solve_quad(BIO *bp, BN_CTX *ctx)\n{\n    BIGNUM *a, *b[2], *c, *d, *e;\n    int i, j, s = 0, t, ret = 0;\n    int p0[] = { 163, 7, 6, 3, 0, -1 };\n    int p1[] = { 193, 15, 0, -1 };\n    a = BN_new();\n    b[0] = BN_new();\n    b[1] = BN_new();\n    c = BN_new();\n    d = BN_new();\n    e = BN_new();\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        for (j = 0; j < 2; j++) {\n            t = BN_GF2m_mod_solve_quad(c, a, b[j], ctx);\n            if (t) {\n                s++;\n                BN_GF2m_mod_sqr(d, c, b[j], ctx);\n                BN_GF2m_add(d, c, d);\n                BN_GF2m_mod(e, a, b[j]);\n                BN_GF2m_add(e, e, d);\n                if (!BN_is_zero(e)) {\n                    fprintf(stderr,\n                            "GF(2^m) modular solve quadratic test failed!\\n");\n                    goto err;\n                }\n            }\n        }\n    }\n    if (s == 0) {\n        fprintf(stderr,\n                "All %i tests of GF(2^m) modular solve quadratic resulted in no roots;\\n",\n                num0);\n        fprintf(stderr,\n                "this is very unlikely and probably indicates an error.\\n");\n        goto err;\n    }\n    ret = 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    return ret;\n}', 'int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                           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(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_SOLVE_QUAD, BN_R_INVALID_LENGTH);\n        goto err;\n    }\n    ret = BN_GF2m_mod_solve_quad_arr(r, a, arr, ctx);\n    bn_check_top(r);\n err:\n    OPENSSL_free(arr);\n    return ret;\n}', 'int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, 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(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_SQR, BN_R_INVALID_LENGTH);\n        goto err;\n    }\n    ret = BN_GF2m_mod_sqr_arr(r, a, arr, ctx);\n    bn_check_top(r);\n err:\n    OPENSSL_free(arr);\n    return ret;\n}', 'int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[],\n                        BN_CTX *ctx)\n{\n    int i, ret = 0;\n    BIGNUM *s;\n    bn_check_top(a);\n    BN_CTX_start(ctx);\n    if ((s = BN_CTX_get(ctx)) == NULL)\n        goto err;\n    if (!bn_wexpand(s, 2 * a->top))\n        goto err;\n    for (i = a->top - 1; i >= 0; i--) {\n        s->d[2 * i + 1] = SQR1(a->d[i]);\n        s->d[2 * i] = SQR0(a->d[i]);\n    }\n    s->top = 2 * a->top;\n    bn_correct_top(s);\n    if (!BN_GF2m_mod_arr(r, s, p))\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}', 'static unsigned int BN_STACK_pop(BN_STACK *st)\n{\n    return st->indexes[--(st->depth)];\n}']