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


test/bntest.c:500:13: Call
498.           BN_bntest_rand(d, 1024, 0, 0);
499.           for (j = 0; j < 2; j++) {
500.               BN_GF2m_mod_mul(e, a, c, b[j], ctx);
                   ^
501.               BN_GF2m_add(f, a, d);
502.               BN_GF2m_mod_mul(g, f, c, b[j], ctx);

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:502:13: Call
500.               BN_GF2m_mod_mul(e, a, c, b[j], ctx);
501.               BN_GF2m_add(f, a, d);
502.               BN_GF2m_mod_mul(g, f, c, b[j], ctx);
                   ^
503.               BN_GF2m_mod_mul(h, d, c, b[j], ctx);
504.               BN_GF2m_add(f, e, g);

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:503:13: Call
501.               BN_GF2m_add(f, a, d);
502.               BN_GF2m_mod_mul(g, f, c, b[j], ctx);
503.               BN_GF2m_mod_mul(h, d, c, b[j], ctx);
                   ^
504.               BN_GF2m_add(f, e, g);
505.               BN_GF2m_add(f, f, h);

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:500:13: Call
498.           BN_bntest_rand(d, 1024, 0, 0);
499.           for (j = 0; j < 2; j++) {
500.               BN_GF2m_mod_mul(e, a, c, b[j], ctx);
                   ^
501.               BN_GF2m_add(f, a, d);
502.               BN_GF2m_mod_mul(g, f, c, b[j], ctx);

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.   {

crypto/bn/bn_gf2m.c:489:11: Call
  487.           goto err;
  488.       }
  489.       ret = BN_GF2m_mod_mul_arr(r, a, b, arr, ctx);
                   ^
  490.       bn_check_top(r);
  491.    err:

crypto/bn/bn_gf2m.c:418:1: Parameter `ctx->stack.depth`
    416.    * the result in r.  r could be a or b; a could be b.
    417.    */
    418. > int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
    419.                           const int p[], BN_CTX *ctx)
    420.   {

crypto/bn/bn_gf2m.c:432:5: Call
    430.       }
    431.   
    432.       BN_CTX_start(ctx);
               ^
    433.       if ((s = BN_CTX_get(ctx)) == NULL)
    434.           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:462:5: Call
    460.   
    461.    err:
    462.       BN_CTX_end(ctx);
               ^
    463.       return ret;
    464.   }

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_mul` 
        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_mul()\n{\n    BIGNUM *a, *b[2], *c, *d, *e, *f, *g, *h;\n    int i, j, st = 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    f = BN_new();\n    g = BN_new();\n    h = 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, 1024, 0, 0);\n        BN_bntest_rand(c, 1024, 0, 0);\n        BN_bntest_rand(d, 1024, 0, 0);\n        for (j = 0; j < 2; j++) {\n            BN_GF2m_mod_mul(e, a, c, b[j], ctx);\n            BN_GF2m_add(f, a, d);\n            BN_GF2m_mod_mul(g, f, c, b[j], ctx);\n            BN_GF2m_mod_mul(h, d, c, b[j], ctx);\n            BN_GF2m_add(f, e, g);\n            BN_GF2m_add(f, f, h);\n            if (!BN_is_zero(f)) {\n                printf("GF(2^m) modular multiplication test failed!\\n");\n                goto err;\n            }\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    BN_free(g);\n    BN_free(h);\n    return st;\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}', 'int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx)\n{\n    int zlen, i, j, k, ret = 0;\n    BIGNUM *s;\n    BN_ULONG x1, x0, y1, y0, zz[4];\n    bn_check_top(a);\n    bn_check_top(b);\n    if (a == b) {\n        return BN_GF2m_mod_sqr_arr(r, a, p, ctx);\n    }\n    BN_CTX_start(ctx);\n    if ((s = BN_CTX_get(ctx)) == NULL)\n        goto err;\n    zlen = a->top + b->top + 4;\n    if (!bn_wexpand(s, zlen))\n        goto err;\n    s->top = zlen;\n    for (i = 0; i < zlen; i++)\n        s->d[i] = 0;\n    for (j = 0; j < b->top; j += 2) {\n        y0 = b->d[j];\n        y1 = ((j + 1) == b->top) ? 0 : b->d[j + 1];\n        for (i = 0; i < a->top; i += 2) {\n            x0 = a->d[i];\n            x1 = ((i + 1) == a->top) ? 0 : a->d[i + 1];\n            bn_GF2m_mul_2x2(zz, x1, x0, y1, y0);\n            for (k = 0; k < 4; k++)\n                s->d[i + j + k] ^= zz[k];\n        }\n    }\n    bn_correct_top(s);\n    if (BN_GF2m_mod_arr(r, s, p))\n        ret = 1;\n    bn_check_top(r);\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}']